rsammy Posted April 30, 2008 Share Posted April 30, 2008 i need to get the current time of another time zone. for instance, i am in the EST. I need to insert the current time (into a MySQL database) as PST although I am in EST. The server could be anywhere, EST, PST or even GMT. But, I need to insert the current time of a particular zone(say, PST in this case). I am working on an application for my office. My office is in CST. But I live in EST. And, the server where our files are FTPd is in PST. So, when i work from home, the records are entered in EST as against the standard office time of CST. The records should have the CST time and not EST or PST. Can someone help? Link to comment https://forums.phpfreaks.com/topic/103633-get-current-time-from-another-time-zone/ Share on other sites More sharing options...
corbin Posted April 30, 2008 Share Posted April 30, 2008 Unix timestamps are always GMT, and it's when you do date() or something similar that the timezone is taken into consideration.... I don't know if that helps you or not... How are you storing the dates? A unix timestamp? Text? Or what? Link to comment https://forums.phpfreaks.com/topic/103633-get-current-time-from-another-time-zone/#findComment-530688 Share on other sites More sharing options...
rsammy Posted May 1, 2008 Author Share Posted May 1, 2008 thanx for your reply! im storing date as a string. i format it into yyyy-mm-dd and insert it. i really need to get the time correct here as its messing up the order of transactions(sort order, especially). this is how im inserting into the database: INSERT INTO visit_mgr(visit_phy_id, visit_pat_id, visit_pat_ssn, visit_type, visit_palm_db_id, visit_status, visit_loc, visit_room_no, visit_date, visit_time, visit_date_time, visit_timestamp, client_id, palm_tran_ID, visit_pat_first_name, visit_pat_last_name, visit_pat_dob, visit_pat_sex, visit_user_id) VALUES ('$pat_phy_id', '$PatientSSN', '$PatientSSN', 'ICN', '$dcn_db_id', 'AdmitStatus', '$AdmitVisitLocation', '$AdmitRoomNo', '$datequery', '$timequery', '$visit_date_time', '$now', '$client_id', '$dcn_db_id', '$PatientFirstName', '$PatientLastName', '$pat_dob_reformat', '$pat_sex', '$user_id') $datequery and $timequery(i know thats not how i name variables - didnt know what to name them ) are the date and time values i get by executing this query: $querytime="select Date_Format(curdate(), '%Y-%m-%d') as datequery, Time_Format(curtime(), '%H:%i:%s') as timequery"; $resulttime=mysql_db_query("$database[dbname]", $querytime); $rz=mysql_fetch_array($resulttime); $datequery=$rz["datequery"]; $timequery=$rz["timequery"]; and visit_date_time is the combination of $datequery and $timequery: $visit_date_time=$datequery. " " .$timequery; hope this makes it clear. i need to get this time to reflect the office time(which is CST and not EST where i live). any help will be great help. thanx Link to comment https://forums.phpfreaks.com/topic/103633-get-current-time-from-another-time-zone/#findComment-531021 Share on other sites More sharing options...
Fearpig Posted May 1, 2008 Share Posted May 1, 2008 Corbin had good advice... Use a Unix Timestamp to record you date/time and that should correct your problem. Link to comment https://forums.phpfreaks.com/topic/103633-get-current-time-from-another-time-zone/#findComment-531062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.