Does current_time('timestamp') have an issue?

I am trying to get the current_time('timestamp'), and instead of giving me my current time:

Jun 26 2013 14:30

It gives me:

Jun 26 2013 21:30

I tried to check the seconds, and it gives me:


Which is correct for the time given, but not for the real current time. What's happening?


The output of current_time('timestamp') should be

time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );

according to WP 3.5.2, so you should check your get_option( 'gmt_offset' ) settings.

Also current_time('timestamp', 1 ) should give you time().

| improve this answer | |

It's a WP non-code programming thinking error.

Under General Settings > Timezone

It should be set to your own timezone.

| improve this answer | |

A call current_time( 'timestamp' ) does not strictly speaking give a timestamp, as it depends on the timezone in the WordPress settings. Actual timestamps are always UTC:

Unix timestamps are always in UTC and do not have any other timezone attached.

(from Codex https://codex.wordpress.org/Function_Reference/current_time)

The use of current_time( 'timestamp' ) is currently discouraged: https://core.trac.wordpress.org/ticket/40657

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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