I have a CPT for events. I need to display future events for people to register, while hiding past events.

What is the easiest date format for both (1) entering date when creating new event and (2) comparing event dates with current date ?

2 Answers 2


The date format for entering the date is largely irrelevant. strtotime will convert a lot of different formats to UNIX time. Just make sure your input format makes sense to your users and make sure that your feed strtottime a format that correctly converts to UNIX time. If you are storing data in the *_postmeta table, that is what I'd most likely do since ordinary math works on UNIX time so numeric comparisons work and because most of PHP's builtin date/time functions would require you to convert to UNIX time anyway. Even the MySQL database can work date logic using FROM_UNIXTIME.

That isn't the only option. If you have your own table you could store in one of MySQL date/time formats and the database can work some date logic for you.

If you don't need any complex date logic you can store as YYYYMMDD and the date will sort correctly using ordinary math. That is is the only human date format that does sort correctly using ordinary math. It doesn't work well if you want to pick "all dates in May of any year" or all "January 1st events"-- that sort of thing.


I would suggest storing the dates in DATETIME format as in YYYY-MM-DD HH:MM:SS as it would then be easier to use MySQL to compare values.

As for the frontend user interface just convert it to DATETIME format.

Your Answer

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

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