On my app users can posts comments and specify the comment's expire datetime.
The process is simple:
They choose a date and the date is inserted inside DB with the comment by PHP in format (Y-m-d H:m:s).
Then when i visualize comments i put a JS countdown on each one comment.
Countdown is calculated by JS from the current JS datetime until the DB stored expiration_datetime CONVERTED IN JS,and this is for each one comment.
So i'm wondering while, inserting i use PHP, then outputting i use JS, will this produce any problem related to timezones and user's browsers datetime vs server datetime?
in PHP i do:
$expiration_datetime = date('Y-m-d H:m:s');
in JS i convert :
var expiration_datetime = new Date(<?php $expiration_datetime[0]?>,<?php $expiration_datetime[1]?>,<?php $expiration_datetime[2]?>,<?php $expiration_datetime[3]?>,<?php $expiration_datetime[4]?>,<?php $expiration_datetime[5]?>,);
So i'm wondering if converting datetime by JS will produce any kind of problem for users with different timezones, at the end, what you suggest to pay attention on, or to do, for using best practices out there?
MORE ABOUT:
i'm thinking that maybe setting server and js fixed timezone for dates and datetimes will be unique for all users coming to site, did you agree?