Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to store the current time using the update_option and then compare it if the set time was 3 days ago. I want to know in what format I should store the time? and then how can I compare it with current time and find the difference in the days?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You should store the time as a unix time stamp then you can use human_time_diff to compare.

echo human_time_diff( get_the_time('U'), current_time('timestamp') );

If the difference is more than 24 hours difference it will return the value in days.

share|improve this answer
add comment

Your Answer

 
discard

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.