WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make a function that will check the time associated with a future event (cpt) with the current time, to see if the event has past. When I first collect the time it is in seconds and I can then convert it easily with date_i18n() to whatever, but I am not sure how to compare that results with the wordpress function the_time() to retrieve the current time.

Is there a way to have the_time() spit out the result in seconds, and I can then compare the two simply by ><= ?

or is there a way to compare two dates formatted in the same way? So formatting my date_i18n() result the same way as the_time() result and then comparing somehow

share|improve this question
up vote 1 down vote accepted

the_time() doesn't return the current time, it returns the time of the current post, also it echoes the result.

If you need the current time, simply use PHPs native time() function.

share|improve this answer
Thanks for your help, that accomplished exactly what I was looking for – Kyle Oct 12 '12 at 17:40

Your Answer


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.