Advanced Custom Fields
Date Time Picker (8 posts)

  1. dekzgimutao
    Posted 4 years ago #

    This is very useful plugin by the way, Can i ask if is there an easy way to add timepicker or simple do both datetimepicker in a fields thanks this is the only thing missing for my project thanks,


  2. jhpf
    Posted 4 years ago #

    I found this http://trentrichardson.com/examples/timepicker/ which should do the job but I've had no luck integrating it into /core/fields/date_picker/date_picker.php

    Any help would be great.

  3. xanderashwell
    Posted 4 years ago #

    Elliot has a register_field function now which is great for extending ACF:
    Creating and registering your own field

    I've used the timepicker extension above, and Elliot's own datepicker field, to create a time field.

    Download these files, unzip and install in your theme directory.

    Add the following code to your functions.php file:
    register_field('xa_time_field', dirname(__FILE__) . '/custom-fields/timepicker/time_picker.php');

    (amend the appended URL as you wish, if necessary)

    You should now have a "Time" field type in Advanced Custom Fields!

    Around about line 158 in time_picker.php is where you can alter whether the JS displays datetimepicker or just timepicker.

    You might want to play around with data_date-format,data_time-format and the format of the date string to get the output you desire.

    Hope that helps.

  4. Geet Jacobs
    Posted 4 years ago #

    xanderashwell, very cool was just looking to solve this!

    I think the zip file on dropbox is corrupt, least from the 3 unzip programs I tried. Might try to write my own files but seemed to perfect that you just adding this 1 hour ago!

    Thank you

  5. xanderashwell
    Posted 4 years ago #

    Hi Geet,

    Try again, the zip file was corrupt at my end as well - I'll also stick a copy up on github when I get a chance.

  6. bisrandom
    Posted 4 years ago #

    Hi Xanderashwell,

    This is exactly what I've been looking for .. but I'm just having some trouble implementing it ..... I've copied the files over .. checked the url is correct ... added the register field to my functions.php

    The 'Time' field becomes available, however it just doesn't seem to function correctly. It doesn't bring up a selector ... just allows me to type in the custom field box.

    to try to figure out what I was doing wrong I edited the time_picker.php file and on line 158 I changed it to datepicker .. to test if that would work and it was fine (the date selector displayed as expected) ... I just can't get timepicker or datetimepicker working.


    Any ideas? Many thanks!

  7. daveleeone
    Posted 4 years ago #

    thanks @xanderashwell for posting your code. It works very well :-)

  8. bisrandom
    Posted 4 years ago #

    Hi daveleeone,

    Can I please ask what you changed line 158 to ?

    I've tried both:

    but can't get it to work ... if I change it back to datepicker it works fine ...


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic