41

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() ?

3 Answers 3

77
get_option('date_format');
get_option('time_format');
2
  • 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, 2010 at 19:23
  • very nice, thanks a lot... didnt knew i could do that :)
    – Sagive
    Apr 4, 2012 at 19:51
15

You want get_option(). In particular:

$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
0

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 :)

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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