0

I'm developping a website (PHP/MySQL based) which shows posts and where people can only see certain types of posts once their "releasing" date is reached and not before, for example.

So far I've been using:

  • $released_date = date("Y-m-d H:i:s"); in my script to save any date in my db as a datetime
  • NOW() > released_date in my mysql request to retrieve specific posts
  • time() > strtotime($data['released_date']) in my php script to display or hide specific features within posts

But I'm realizing that these might not be compatible together (at least, the last one vs the first 2) and some time zone issues seem to occur. How can I make these three compatible somehow?

I need my website to "work the same way" independantly from where the user sits, anywhere in the world. Meaning that, if a post's date has reached a specific value, then everybody can see it and use certain features in it.

What would be the best strategy for this? Synchronize everything with the unix timestamp? with my server time value?

I really got lost here...

Any help and/or advices are greatly appreciated! Thank you in advance!

Lois

Lois
  • 77
  • 8
  • So it seems that the best way is, for my case at least, to only work with UTC: meaning, to use gmdate() when saving a date, instead of date(). To use UTC_TIMESTAMP() in mysql requests instead of NOW(). And to use this argument in strtotime: time() > strtotime($date['date_stored_in_UTC_format']." UTC") – Lois Oct 21 '13 at 13:22
  • A common approach is using the [current time in millis since the UNIX epoch](http://currentmillis.com) which is UTC so it's synchronized all across the world. – Sandman Oct 26 '13 at 07:06

0 Answers0