3

Is it possible to set timezone as client's timezone when visit my page? let say if anyone visit my site from america then my script would be

date_default_timezone_set($dynamic_timezone);//this would be as follows
date_default_timezone_set('America/New_York');

again anyone visit my site from dhaka then

date_default_timezone_set($dynamic_timezone);//this would be as follows
date_default_timezone_set('Asia/Dhaka');

I have found a solution which is JS script able to get client timezone. But how can I send the timezone in date_default_timezone_set() or any other solution? I need this so that user can see own local datetime (datetime come from my mysql timestamp field)

Rejoanul Alam
  • 5,435
  • 3
  • 39
  • 68

1 Answers1

0

You can use the Date Object. This piece of code returns the current time from the clients browser, Hence your clients will see their local-time.

currentTime = new Date();
time = currentTime.getTime();
hours = currentTime.getHours();
Domain
  • 11,562
  • 3
  • 23
  • 44