Date and Time Picker field for Advanced Custom Fields


This is an add-on for the Advanced Custom Fields (ACF) WordPress plugin, that allows you to add a Date and Time Picker field type. Works with ACF v3 and v4.


  • 2.0.12 Added support for date format dd/mm/yy + bug fix
  • 2.0.11 Added option to retrive field values, using the_field() and get_field(), as a timestamp
  • 2.0.10 Removed “value” from defaults
  • 2.0.9 Thanks to flahertydaf, the plugin is now working with the latest ACF version. Also replaced DateTime::createFromFormat (PHP 5 >= 5.3.0), with strtotime and did minor bugfixes
  • 2.0.8 Adds option to store the date and time field as a UNIX timestamp or not.
  • 2.0.7 Bug fix. 2.0.6 assumed that the stored date and time was in UNIX timestamp format. 2.0.7 will check and only convert if the date and time is.
  • 2.0.6 Changed how the Date and Time Picker field is triggered when ACF adds a new Date and Time Picker field to the DOM. Saves the Date and Time Picker field as an UNIX timestamp to MySQL. Use the PHP date function when you use it in your theme.
  • 2.0.5 When enqueuing JavaScripts, replaced dependecy of jquery-ui-datepicker with acf-datepicker
  • 2.0.4 Updated JavaScript language detection and loading
  • 2.0.3 Fixed Repeater field bug. Added support for including the field in a theme
  • 2.0.2 Total rewrite, based on the acf-field-type-template. Works with ACF v3 and ACF v4.
  • 1.2.0 Updated jquery-ui-timepicker-addon.js to the latest version (1.0.0) and added localization support.
  • 1.1.1 Fixed a small bug
  • 1.1 Change name to Date and Time Picker to reflect the new option to select between Date and Time picker or Time Picker only. Thanks to Wilfrid for point this out (not sure why I didn’t include it in 1.0)
  • 1.0: Initial version

Latest version


Advanced Custom Fields WordPress plugin installed and activated.


This add-on can be treated as both a WP plugin and a theme include.

Install as Plugin Copy the ‘acf-date_time_picker’ folder into your plugins folder Activate the plugin via the Plugins admin page

Include within theme This doesn’t work at the moment, I’m looking into it.Copy the ‘acf-date_time_picker’ folder into your theme folder (can use sub folders). You can place the folder anywhere inside the ‘wp-content’ directory Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-date_time_picker.php file)

Create a Date and Time Picker field

Add Date and Time Picker field
To set the date and time format when you create the field, you have to create a string using the letters below. Date format

d    day of month (no leading zero)
dd   day of month (two digit)
o    day of the year (no leading zeros)
oo   day of the year (three digit)
D    day name short
DD   day name long
m    month of year (no leading zero)
mm   month of year (two digit)
M    month name short
MM   month name long
y    year (two digit)
yy   year (four digit)

Time format

H    Hour with no leading 0 (24 hour)
HH   Hour with leading 0 (24 hour)
h    Hour with no leading 0 (12 hour)
hh   Hour with leading 0 (12 hour)
m    Minute with no leading 0
mm   Minute with leading 0
s    Second with no leading 0
ss   Second with leading 0
l    Milliseconds always with leading 0
t    a or p for AM/PM
T    A or P for AM/PM
tt   am or pm for AM/PM
TT   AM or PM for AM/PM


  • yy-mm-dd: 2013-04-12
  • HH:mm: 24 hour clock, with a leading 0 for hour and minute
  • h:m tt: 12 hour clock with am/pm, no leading 0

Retrieving Time Picker values

To get a general understanding on how to retrieve values from ACF, see the examples in the ACF Documentation.

Simple example

Get the field in the same format as you set it when you created the field, using get_field():

Changing date and time format

When adding a date-and-time field, choose “Get field as timestamp” and use date_i18n to do something like this:

Together with the repeater field

Here’s how I retrieve that values from the example in the screen shot


The plugin will, based on WPLANG in wp-config.php, try to load the correct localization/jquery-ui-timepicker-LOCALE.js file.

If your language doesn’t exist in localization/jquery-ui-timepicker-LOCALE.js, you have to do the translation your self:

  1. In acf-date_time_picker/lang, copy acf-date_time_picker.po to acf-date_time_picker-languagecode_COUNTRYCODE.po e.g: acf-date_time_picker-nb_NO.po
  2. Edit the file using poedit or its like, and save the .mo file in acf-date_time_picker/lang


If you suspect that acf-date_time_picker doesn’t enqueue the scripts in the right order, install acf-debug-list-enqueued-scripts and add the field “ACF DEBUG: List Enqueued Scripts” to your fields. When you open Posts->Add New, you should get a list like the following:


Date and Time Picker field for Advanced Custom Fields uses the jQuery timepicker addon by Trent Richardson. Copyright 2012 Trent Richardson. Dual licensed under the MIT and GPL

134 thoughts on “Date and Time Picker field for Advanced Custom Fields

    1. PerS Post author

      In hindsight, I agree. I will update it this plugin to let you choose between DateTime picker and Time picker.

    1. azyogadude

      i am trying to extract hour & minute from date time picker but has no idea what function to use .


  1. Tai

    Am having issues :) On posts the date / time picker field is just displaying as a text field. When you click on it the date / time picker is not loaded. I have tried disabling other plugins, removing other jquery scripts I was using and removing other custom acf fields. Any ideas?

    WordPress: 3.3.1
    Acf: 3.1.6

    1. PerS Post author

      Have you tested for javascript errors (using firebug etc) ?

      I’m also running WordPress 3.3.1 and ACF 3.1.6, and I can’t find any errors.

    2. PerS Post author

      .. also, do a view-source and see if the links to the following files exist and are correct:

      • acf_time_picker/js/jquery-ui-timepicker-addon.js
      • acf_time_picker/js/timepicker.js
      • acf_time_picker/css/jquery-ui.css
      • acf_time_picker/css/timepicker.css
  2. Dale Jacobs

    Great plugin, thank you!

    I trying to get the saved data to be yyyy-mm-dd hh-mm in the database, but display mm/dd/yy hh:mm for the editor section.

    Editing your custom field, I thought I could use the update_value function to do the saving of the new date format with the below:

    // do stuff with value
    //$value = date(“Y-m-d g:i”, strtotime($value));

    But it doesn’t seem to be firing the update_value, and just saving the default field value that is shown.

    My plan was the than to grab the value and display it differently for the edit post screen with the below:
    value=”‘ . date(“m/d/Y g:i”, strtotime($value)) . ‘”

    Do you happen to have any idea why the Update_value is not working on save?

    Maybe this would be an option to add for the plugin if we can get it working? This was sorting with WP_Query and date/time field would sort correctly but the client would still see a pretty date format in the admin section.

  3. Tai

    Ah yes, was a space in my theme name >.< so was incorrect path to js and css files.

    Awesome plugin extension, cheers

  4. PerS Post author

    Hi Dale,

    This is my first add-in to ACF. I’ll dive into the code and see if I missed something (haven’t looked at Update_value, so I must be missing something). I’ll post here when/if I find a fix.

  5. PerS Post author

    update_value in my add-in is triggered. I added the following to log what was happening:

    And got this in acf_time_picker/log/log.txt ( acf_time_picker/log is world writable):

    1. Dale Jacobs

      I wonder what I am doing wrong.

      Here is the function I edited, I am using the basic srtoftime to take out any extra variables. The field has “mm/dd/yy hh:mm” in it. After saving, it uses that format instead of stroftime. When you ran the test did it update the date post_meta in the database with the new value?

      From the log it would mean it might be on ACFs end?

      Thank you for taking the time on this.

      1. PerS Post author

        Just tested and it worked fine, got 1333589100 when I retrieve the value in my theme. Are you sure you are retrieving it correctly ?

        1. Dale Jacobs

          Firstly I want to apologize for using your pressure time on an issue that was my fault. I had duplicated an advanced custom post type post, so in the post meta there were two “start_date” fields with the same field_randomstrings. I deleted the duplicate field and created a new Start Date and it works as its meant too, again I feel bad I used your time (also wasting hours of my own!)

          Maybe adding a checkbox to save unix or wordpress date stamp in database could be an option you add in any future release?

          For anyone else who wants to be hack/show a clean date for the client, but add a database entry that will be easily sortable by queries, you can use the below code.

          In the file acf_time_picker.php in the function “update_value” add the line below. This will add the date format as normal post dates.

          Then to show a different date for the client in the admin section and front end add the below line to “get_value” function.

          With the above make sure to set the php date format to what you set when you added the timepicker field.

          1. PerS Post author

            No problem Dale, glad you got it to work.

            I’ll look into adding this option to the add-in, it’s a good idea.

  6. ikemarrus

    I’m getting these warning messages when I try to define a timepicker field:

    Notice: Use of undefined constant acf – assumed ‘acf’ in path/acf_time_picker/acf_time_picker.php on line 104

    Notice: Use of undefined constant acf – assumed ‘acf’ in /path/acf_time_picker/acf_time_picker.php on line 105

    1. PerS Post author

      Yepp, you are correct. Thank you for notifying me. It’s fixed and a new version is available in the download link above.

  7. Stian Andreassen

    Brilliant plugin! Thanks, Per!

    Is there any way to use localization? The jQuery timepicker comes with language files, yes?

    1. PerS Post author

      Selvsagt :)

      The following is localized:

  8. Stian Andreassen

    Hur bra som helst! ;-)

    Would be great if there was localization for names of days and months.

    1. PerS Post author

      I see what you mean. I will add localization for days and months using jquery-ui-i18n.min.js, but I don’t have time until next week-end.

    2. PerS Post author

      The latest version, supporting localization, is available (got some spare time). Please test

  9. Jonny

    Using get_stylesheet_directory_uri() to enqueue scripts is not good practice as it makes assumptions about where the script will be located which is always a bad idea. Better to use dirname(__FILE__).

    1. PerS Post author

      Eh .. I was a bit quick. According to the wp_enqueue_script() documentation, the $src parameter should “use plugins_url() (for Plugins) and get_template_directory_uri() (for Themes) to get a proper URL”.

      I’m open to reconsider, but then your argument, with example code, must be good ;)

      1. Jonny

        plugins_url(script_file, __FILE__) would be the correct way to do it I think where script_file is the script filename relative to the plugin directory.

  10. Su

    I’m seeing similar behavior to Tai above(unresolved), but in looking into things, there’s something weird going on:

    1. The stylesheets and scripts required by the field /are/ being included in the source…
    2. …but their URLs result in a 404 page from WordPress…
    3. …but only due to the query parameter.

    So for example, the jQuery UI CSS is being loaded via:
    That URL produces a 404 screen, but:
    loads properly.

    This is happening for the resources your field is loading ONLY. I have all sorts of other plugins loading various things on this install.
    One thing possibly worth noting is that yours is the only code that’s pulling CSS/JS from the theme directory to the admin area. Maybe there’s some kind of edge case there? I don’t think I’ve seen it done before.
    I’m using WP 3.4.

    I’m going to try and repro this later on a cleaner, unrelated installation and/or add plugins back in to see if there’s a conflict, but wanted to document in case someone can do anything with just this.

    1. PerS Post author

      Hi Su,

      Thank you for your thorough feedback.

      Before I dig into the WordPress source; Have you flushed the permalink cache after you upgraded to 3.4 ? You flush the permalink cache by re-saving your permalinks in wp-admin >> settings >> permalinks

      1. Su

        It must’ve been something along that line. Unfortunately, it’s “fixed itself” so I can’t absolutely confirm. I’d already deleted the custom field and removed the include code from functions.php, and after re-adding them just now the picker comes up properly.

        I’m pretty sure that in the interim I did /not/ modify any content or the permalink settings(it’s a dev install and I’m only doing theme work), but I assume that cache is periodically rebuilt on its own.

        I’ve still got some things to do in there, so I’ll try and pay closer attention to see if it comes up again.

        1. PerS Post author

          Isn’t it fun when things “fixes itself” :)

          Please don’t hesitate to contact me if it happens again (or if you find new bugs).

  11. Brent

    Great add-on! However, I’m having trouble querying a Date/Time field and sorting by the value. Has anyone else had success with this? Thanks.

  12. zander


    the files aren’t linking properly in the source – it seems to be being caused by the version number which is beign put into the head… so the link in my source is ‘a href=’′

    that url resolves without the version number. so how do I stop it enqueing with the version number?

  13. Sascha


    For me the date / time picker is not displayed.
    It seems as if the two JavaScript files are not included. But the two CSS files, however, are involved.
    What can I do?

    1. PerS Post author

      Excellent, you had me worried. You’re the only one that’s reported this “bug”. What’s the name of the other plugin ?

  14. TheWalker


    Very nice add-on for ACF!
    I changed the function get_value and update_value, to change the format of date, without change the format of input to user.
    The reason for do that, is get posts ordered by date and time using the meta_query.

    Input: dd/mm/yy hh:mm
    Saved Field: yy-mm-dd hh:mm

    I don’t know if this is the right way, because the user can select Date and time, or only time in custom fileds configuration.

    The code:

  15. niek

    Hi guys,
    Am struggling to find the right info on how to adjust the way the date displays on my site, currently like this: 20121129, and should be: 29 November 2012. Any advice would be much appreciated!

      1. niek

        Thanks, I’d hoped it was that simple, but actually I need it to display that on the actual site, not just in the admin… ?

        1. PerS Post author

          It will have the same format as in the admin, as long as you don’t modify the data in update_value. If you do, you have to reformat it before you display it in your theme.

  16. Carl Wilhelm

    Okay, so I tried installing this addon, and now my site has gone haywire:

    Warning: include(/PATH/wp-content/themes/arthemia/acf_time_picker/acf_time_picker.php) [function.include]: failed to open stream: No such file or directory in /PATH/wp-content/plugins/advanced-custom-fields/acf.php on line 218

    Warning: include() [function.include]: Failed opening ‘/PATH/wp-content/themes/arthemia/acf_time_picker/acf_time_picker.php’ for inclusion (include_path=’.:/usr/share/pear:/usr/share/php:/PATH/wp-content/plugins/mailchimp-widget/lib’) in /PATH/wp-content/plugins/advanced-custom-fields/acf.php on line 218

    Fatal error: Class ‘acf_time_picker’ not found in /PATH/wp-content/plugins/advanced-custom-fields/acf.php on line 220

    Any suggestions?

    1. PerS Post author

      Looks like you have an error in arthemia/functions.php where you include the time picker field. Please post what you added.

  17. Carl Wilhelm

    Never mind, the addon works just fine. I put the addon-files in the wrong place.

    Thanks for this! This is going to make things a lot easier. I find it weird that isn’t a standard feature in ACF to be honest.

  18. Carl Wilhelm

    For some reason, the buttons for the next and previous months are missing from the date & time picker window. It’s worked a few times before, but I can’t figure out what’s wrong. One thing I’ve noticed is that when the buttons are missing, the background for header where the name of the month is displayed is blue. When the buttons are there the header background is gray. Could this stem from a plug-in conflict or something like that?

      1. Szymon Skulimowski

        Thats right but this plugin is “Advanced Custom Fields” :)

        You should simple add this line into acf_time_picker/css/jquery-ui-timepicker-addon.css:

  19. Alicia St Rose

    Hi PerS,
    Just downloaded this addon. It looks like it’s just what I need. But I can’t seem to make it work! Added the files but I’m getting a text field and no time picker. I’m a noob don’t know what doing wrong…

  20. Alicia St Rose

    Hi PefS,
    Turns out my client doesn’t need a time picker. I will revisit this in the future and add the debug file to see what the problem is. Thanks for your quick response!

  21. David Mosterd


    Great stuff this time picker. I have made a change to it and hope you will add this to your code. (Why not place it in github so we can all do pull requests?)

    I found it rather a pain that I was forced to place this into my theme folder as I like to keep external things organized. Now it takes __FILE__ and assumes it’s somehwere in the themefolder.

    Check it out. But I have even an better idea. Why not place it on github and lets make this into a plugin? That will be just…. right.

    Let me know if your up to it, if not, I will do it myself but I rather have the original author do this of course.



  22. David Mosterd



    It now uses __FILE__ so you can place it anywhere in your theme.

    If you are up to it: why not make this into a GitHub repo and turn this jewel into a plugin?
    We can use GItHub to develop and use the official WP repo to distribute this.

    Let me know if you are up to it! Or is there a secret GitHub? Could not find it ;)

  23. eaglejohn

    It seems that the add-on “Date & Time Picker” doesn’t work in v4.0 Beta? I’ve used it before in v3.5.8.1 without problems. Any suggestions?

    1. PerS Post author

      Thank you for telling me. I haven’t tested it myself with 4.0 (since it’s still in beta), but will have a look this week-end.

      1. eaglejohn

        Elliot (ACF developer) replied to my post on the ACF support forum and he told me he has to fix it because things work different in 4.0 (beta).

  24. ColouRo

    I installed the plugin, but have one problem.
    When I click on input I get this error:
    Uncaught TypeError: Object [object Object] has no method ‘datetimepicker’

    Maybe someone knows how to fix it?

  25. Elliot Condon

    Hi Guys,

    I’m Elliot, the dev behind ACF and just wanted to say hi, thank you for making this field and also chat about the new ACF v4.

    Unfortunately, in v4, I have had to change the way in which we define custom field types, this means your field is not compatible with the new ACF and wont work.

    This said, it will not require much work at all to create a v4 compatible field type!
    Please read the new documentation for creating a field type here:

    You will find that some functions have changed names. I advise that you start with a blank dummy.php field file and copy across your old functions one by one into the new function spaces.

    I’m more than happy to help out with creating a v4 compatible field type, just let me know.

    I’m not sure if you would want to create a new repository or just a new branch, but either way, both versions will need a url for users to find.

    I’m sorry about causing any extra work and hassle, thanks for all your hard work, it’s greatly appreciated!


    1. PerS Post author

      Hi Elliot, I’m on a business trip, but will look at ACF v4 this coming week-end. Thank you for offering your help, I’ll bug you only if needed :)

  26. John Snow

    Hey, if you change “self = jQuery(this);” to “var self = jQuery(this);” on line 6 of timepicker.js it stops causing errors in Internet Explorer 8.

  27. Tim Wood

    I really like this addon – and the slider is great; however, I’ve had a few integrations where it would be helpful if A) it was a dropdown instead of slider & B) if it showed 12 hour time instead of military time. Any chance those are available in upcoming release?

    1. PerS Post author

      Hi Tim, thank you for your feedback.

      Ref A, I guess you want this for mobile users? It’s a good idea and I’ll try to add it as an option in the next release (coming this week). As of B, you have this option today. You set the time format when you create the field.

  28. Enrique

    Thank you for your great contribution. I’ve found that the time is saved in Unix timestamp but when it’s read it takes into account the default timezone set in wordpress. So currently I’m on the UTC+ 2 timezone and if i save 17:00 it returns 19:00.

    The workarround in function load_value in date_time_picker-v4.php

    1. PerS Post author

      Let’s assume the following:
      - the filed name is: mydate
      - your date and time format is: m/d/yy h:m tt

  29. Ben

    Thanks for the great add-on.

    When I set the date format in the date field settings to “dd/mm/yy” it is saving the day as the month, and the month as the day. Can you help?

    It works fine if I use “mm/dd/yy”. I did try reading through the posts above but couldn’t see a solution.

  30. B Bolla


    i’m having issues with changing the date format to 24hr. Current Date format: YYYY-MM-DD hh:mm:ss

    I realise i need to change form hh to HH. But i have no idea how to do this.

    I have installed the plugin “Advanced Custom Fields: Date and Time Picker”

    Please can someone help me as i am limited skills in this area?

  31. B Bolla


    Can someone please help me.

    I have installed the plugin “Advanced Custom Fields: Date and Time Picker”

    Please can someone tell me how to change to a 24hr time?

    I am a complete novice at this and would appreciate some basic instructions!

  32. Scott

    I’ve added a custom field to a custom post type, but it’s not saving (or showing ) the Date Time field value. I’ve tried it with and without the timestamp. And i’ve tried it with the regular post type. I’m running PHP 5.3. Any ideas why my values are not saving?

  33. Scott

    It’s actually saving it in the custom field in the DB so i guess it’s KIND of working. But it’s not showing the value in the meta box field itself. And when i try to resave it, since it’s a required field, it’s needs a new value in the meta box.

  34. Josh Emerson

    I am trying to get the ACF date/time picker to work on a site I am building. It seems like it would be the perfect solution but upon selecting a time and updating the entry, it does not show. If I switch the field type to a text field it shows what seems like a unix time number. Is there a way to get the time picker to display the time I input?

  35. Benjamin A. Wendelboe

    Hey Per,

    Thanks for a great plugin – I am however having a bit of an issue with the time picker, that I was hoping you could help me with..

    When I go back to edit a post, my “time”-field is empty.. I tried changing the field type to “number”, and suddenly the UNIX timestamp shows up, but no matter what else I do to tinker with it, I have to re-enter the value on every edit..

    Any help would be appreciated..!

  36. Larry Woods

    Blows when trying to publish a post with date/time:

    Fatal error: Call to undefined method DateTime::createFromFormat() in …/wp-content/plugins/acf-field-date-time-picker/date_time_picker-v4.php on line 293

  37. Larry Woods

    I am using the date in a POST edit. Any way to get the date do display after I have once entered/updated the POST?


  38. Roger Henriksen

    Ser at du svarer på skandinaviske henvendelser, så jeg prøver på norsk. Dette er kanskje litt ved siden av henvendelse ellers i denne tråden, men håper du har tid til et svar:

    Jeg har et problem med en oversettelse for en kundeside. Jeg bruker Advanced Custom Fields plugin og trenger å få oversatt månedene som bare kommer på engelsk. Jeg skal benytte norsk, spansk, polsk og engelsk på nettsiden og bruker WPML til dette. Jeg har forandret datepicker eksempelvis d. MM yy på norsk og MM d, yy på engelsk for å har riktig visning av dato. Dette gjør jeg i ACF-plugin’ets kontrollpanel. Problemet er altså at MM alltid viser engelsk tekst. Jeg har prøvd å finne oversettelse på dette i WPML, men finner ikke måneden og oversettelsen i .mo-filene fungerer ikke til dette. Hovedspråket på nettsiden er på norsk – om det er viktig informasjon.

    Vet du hvordan jeg evt. gjør dette eller hvor jeg finner oversettelse på måneder? Jeg er egentlig ikke programmerer, så håper på et ikke-teknisk svar :)

    På forhånd takk!

    1. PerS Post author


      Jeg har tatt kontakt med WPML for å bli med på de sitt Go-Global Program , kommer til å legge til WPML-støtte så snart jeg får WPML.

      I dages versjon av pluginet så blir navn på måned og dag blir hentet ut fra $wp_locale og ikke fra en .mo

  39. Mark

    Hi there!

    Is there any way to use this date picker to create a reoccurring event?

    I’m using it to add dates to upcoming events on my website but some of these events occur weekly. At the moment I’m having to go into ever weekly event each week and change the date manually but as the number of weekly events increases it’s becoming a laborious task!

    If there isn’t, does anybody know a way I can get the data straight from the WP database? I’ve set each weekly events post category to “Regular-Event” so I’d need to export the date value for each post with this category, add 604800 seconds then re-import it. I’ve found the date values in the wp_postmeta table but cant figure out how to link this to the Post ID or Term ID!

    Any pointers in the right direction would be much appreciated! :)

    1. PerS Post author

      You can get the value using get_field(), the syntax is:

  40. Toni

    I’d like to see, that the WP timezone is used when you input and review dates and then save time as UTC like it’s now. This greatly enhances the UX and it’s suberb for developer to handle to date/time.

    If you want to avoid gestimation of WP set timezone give an option to choose the timezone.

    What do you think?

  41. Vince

    I am trying to install the date/time picker and am having problems modifying the functions file to make it work. I keep getting an error when I insert the code you suggested into the functions.php file.
    This is the code I am inserting:
    add_action(‘acf/register_fields’, ‘my_register_fields’);
    function my_register_fields()
    Where in the functions.php file do I need to insert?

    Is it correct that the reference ‘acf-date_time_picker/’ is to a folder in my themes/ifeaturepro/ directory…if so I have a folder named /themes/ifeaturepro5/acf-field-date-time-picker/ that does not match the folder reference in your suggested insert. Is this the cause of my problem?
    Your help would be greatly appreciated…thanks.

    1. Per Søderlind Post author

      Just discovered that including the date and time picker in functions.php doesn’t work. For now, please add it as a plugin.

  42. Bob

    hi there,

    great plugin! but:
    What could be the reason that the time format “HH:mm” does not work for me?
    Wordpress forget my 24-hour-format, instead next time I edit my “time”-field, shows me “hh:mm”

    thanks for any advice,

    1. Martijn

      I have the same issue.
      Date as d MM yy and Time as HH:mm
      Saving just clears the field.

      Also had issues saving in other formats, it’s was mixing up the year and months, entered 2014 as year and then it saved as 2020.

      Saving and displaying/using field as timestamp.

  43. Joshua Michaels

    First, great Add-on – thank you!

    I’m having two issues:

    1) I have the date picker date set to yy-mm-dd and Save as Timestamp enabled. But I would like to format the date/time differently at certain locations in my plugin. It says to use the PHP date function but I’m not clear on exactly how to get the field value and then use that function. Can you give a quick example?

    For my purposes, in some places I would like to show the date as 2014-02-28 but in others February 28, 2014, etc.

    2) I’m using ACF in a plugin I’m creating and want to include the date time picker in my plugin (not in a theme). I copied the acf-date_time_picker folder to my plugin folder and I tried using this:

    but I cannot get it to work. It works as a standalone plugin but obviously I would like to include it directly.

    1. Per Søderlind Post author

      Hi Joshua,

      1) When adding a date-and-time field, it you choose to “Get field as timestamp” you can do something like this:

      2) If you’d like to include my plugin in yours (and please feel free to do that), you should add the code from acf-date_time_picker.php to your plugin (i.e. not include acf-date_time_picker.php)

      Feel free to ask if you have any more questions.

      1. Joshua Michaels

        Thanks Per, that worked perfectly. Just offhand, do you know a way to show lowercase am or pm on a Mac? %P is not supported.

        Will add the code to my plugin and see how that goes.

        Thanks for the help!


        1. Joshua Michaels

          If anyone is looking, using Per’s code above to format your datetime:

          would result in: Tuesday, February 25, 2014

          would result in: 5:49pm

        2. Per Søderlind Post author

          I was a bit quick (and tired) when I answered. You should use the WordPress function date_i18n as in

          for lower case am/pm, use “a”

  44. Joshua Michaels

    Trying to only show posts from today or in the future using the date picker. Below is my loop arguments but with this it only shows all event posts (in past and future). What am I missing here?

  45. Frank

    Hey there! Really nice plugin.

    I have several fields on my site that use the “Time Picker” option, and looking in the database, I’m confused as to what format these are being saved in.

    I get a value like: 1392591600
    Which, assuming it’s a timestamp, converts to Sun, 16 Feb 2014 23:00:00 GMT

    The thing is, this field should only be a time, not a date as well, right? I need to access the value directly from the database (i.e. can’t use PHP), and convert to a readable time, and I’m unsure how to parse this without PHP.

    1. Per Søderlind Post author

      Hi Frank,

      You have two option, either save the time as a string (select “No” to save as timestamp when you create the field) or as a timestamp.

      A timestamp (number of seconds since 1/1/1970) will contain a date. If your field is a time field, todays date will be added. You can convert the timestamp to a time value in MySQL using something like this:


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">