jonathan-dejong / simple-jwt-authentication

Extends the WP REST API using JSON Web Tokens Authentication as an authentication method.
GNU General Public License v3.0
87 stars 25 forks source link

problem with GMT & time functions() ? #51

Closed gordielachance closed 5 years ago

gordielachance commented 5 years ago

Hi, I think that there it time issues with your plugin. Should it not better use WP function

current_time( 'timestamp', true );

instead of

time()

?

jonathan-dejong commented 5 years ago

Hi,

Wowsa that's a lot of new issues posted at the same time.

I'm going to have a look at your PR as well :)

As for this specific issue the answer is plainly no. It's not a good idea to use current_time. However if your case is that the date displayed in the UI is a bit off from your local time then that's something that can be corrected by changing the outputting function.

Here's a bit of info from WP Codex itself:

Note that if you are storing the time of an event, current_time( 'timestamp' ) should not be used in lieu of time(), as it returns a Unix timestamp that is incorrectly offset and inaccurate. Unix timestamps are always in UTC and do not have any other timezone attached. Should the site owner change the timezone of the WordPress installation at any time, stored timestamps that are offset using current_time( 'timestamp' ) will be incorrect. Instead of using current_time( 'timestamp' ), which is no longer recommended, use time() and store it unmodified.