Jump to content

get current time from another time zone...


rsammy

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.