php - How to calculate GMT and UTC timestamp -
i have been using php/ mysql long time , have been using unix_timestamp store date,time values. have created timestamp class handle kind of request. source code available on github.
by default, class uses $_server['request_time'] gmt timestamp, believe.
my requirement find out local timestamp in accordance gmt , show user. in other word, need find local time of user , difference gmt in number of seconds using php
how implement these requirements in class. please help
datetime allows accomplish this:
// interpret time utc $timezone = new datetimezone('utc'); $datetime = new datetime('@' . $_server['request_time'], $timezone); // output php's timezone $user_timezone = new datetimezone(date_default_timezone_get()); // or whatever timezone need $datetime->settimezone($user_timezone); echo $datetime->format('y-m-d h:i:s');
Comments
Post a Comment