0

In my system, I am going to use the default time zone as asia/kolkata. If a user accesses from China, is it possible to show the complete system information related to their time zone? How would I implement this?

Note: I am going to use mktime to store all dates in an integer format. i also using the ip2country to find user country.

i having a big confusion in the part of conversion of the time stamp values, if user 1 post something from India, user 2 view from from china displaying time is based o china.

Praveen
  • 33
  • 6
  • AFAIK changing default_time_zone() is inherently a bad idea and should be used only to set a consistent timezone across the server. You should check this link here: http://php.net/manual/en/datetime.settimezone.php – César Aug 08 '16 at 13:20
  • 1
    I don't understand. Is this just to show a user some timezone information when they visit or will you be handling date/time data sent by users? – apokryfos Aug 08 '16 at 13:27
  • 1
    This isn't a bad question at all, and it's actually pretty interesting. If you default to `asia/kolkata` then you should store dates as `timestamp` (in MySQL, or equivalent in your storage layer). Don't use `mktime`, use `DateTime` class that lets you manipulate dates. If a user visits you from another time zone, you should obtain their time zone somehow - the best way is to **ask** the user where they're coming from and then set a cookie with the time zone. If they don't inform you about this, then default to `asia/kolkata`. Using `DateTimeZone` you can manipulate time offsets easily. – Mjh Aug 08 '16 at 13:57

0 Answers0