Ivan Gretsky Posted August 1, 2016 Share Posted August 1, 2016 Good day! I need to have $page->created as a UNIX timestamp (UTC) to compare it to time(). But I can't figure it out how to do it. I get the $page->created time in the future, later than time(). Please help! Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 1, 2016 Share Posted August 1, 2016 Maybe a timezone issue? Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted August 1, 2016 Author Share Posted August 1, 2016 (edited) I am really confused here. Please be so kind to explain. When I get $page->created as a timestamp, should not it be the same as 11 digits not depending on any timezone? But when I create a new page and straight after that do something like this: echo time(); echo $pages->get(1053)->created; The first number is less than the second in an amount of seconds equal to an hour. I assume both of these numbers are UNIX timestamps and should be about the same, but they differ in an hour. Edited August 1, 2016 by Ivan Gretsky Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 1, 2016 Share Posted August 1, 2016 It should in theory, but I had issues where the mismatch came from mysql using another timezone than php, because created is "created" by sql NOW() and not in php afaik. Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted August 1, 2016 Author Share Posted August 1, 2016 Unix timestamp should be the same on any server, shouldn't it be ? Anyways, what should I check to make php and mysql consistent? Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 1, 2016 Share Posted August 1, 2016 http://stackoverflow.com/questions/930900/how-to-set-time-zone-of-mysql 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted August 1, 2016 Author Share Posted August 1, 2016 Yep, already there thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now