Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is a strange question, but I want to know how I can access the Date and Time settings

Admin > Settings > General > Date Format
Admin > Settings > General > Time Format

I am using the Any+Time jQuery plugin as a date/time selector for the editor view for a custom post type. It allows you to specify a date and time format using the same settings WordPress does. Edit: Turns out it doesn't use the same Date part tokens that WordPress does. Lame.

http://www.ama3.com/anytime/#AnyTime.Converter.format

Ideally I want to do something like this...

<?php 
  $wpDateFormat = get_admin_settings('DateFormat');
  // $wpDateFormat now holds something like "F j, Y"
?>

<script>
    $("#datetime").AnyTime_picker({
      format: '<?php echo $wpDateFormat ?>'
    );
</script>

What I don't know is... is there such a function like get_admin_settings() ?

share|improve this question

3 Answers 3

up vote 19 down vote accepted
get_option('date_format');
get_option('time_format');
share|improve this answer
    
Thanks, turns out that the jQuery plugin uses different date and time tokens to specify format after all. So, while this doesn't solve my problem at hand, I appreciate you sharing for my future benefit. –  jessegavin Aug 19 '10 at 19:23
    
very nice, thanks a lot... didnt knew i could do that :) –  Sagive SEO Apr 4 '12 at 19:51

You want get_option(). In particular:

$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
share|improve this answer

Why don't you write a small PHP function that maps the WordPress format specifiers to the Any+Time™ specifiers? Then you can accomplish your goal :)

share|improve this answer
1  
Someone has already written a conversion from php date() to strftime() format, and I think the MySQL format Any+Time uses is compatible with the latter. –  Jan Fabry Oct 7 '10 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.