View Single Post
  #1 (permalink)  
Old 09-25-06, 02:27 PM
Godwin Godwin is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Question Convert to time from a string

Hi,

Ok this may have a simple solution but I couldn't get it work right.

I have 2 columns in the schedule table (hours,mins), which stores the values entered from a form. This would represent the time in singapore format.

My problem is that I want to first convert the singaporean time(GMT +8) to my local time(sri lanka GMT +5.5). For that I need to convert it to GMT first then using offsets I can calculate my local time. So I substract 28800 seconds from the singapore time and now I have the GMT time I can simply convert that to my time zone. But how do I first get the values from hours and mins columns and store it in a variable in time format?


This code below is based on my local time and calculates correctly both in gmt and singapore time.

PHP Code:

$srilanka_time time();

$gmt $srilanka_time - (19800);

$singapore_time $gmt + (28800);
echo 
'GMT is: '.date('H:i'$gmt); 
echo 
'Singapore time is: '.date('H:i'$singapore_time); 

This code below is what I have done to get the GMT time based on singapore time.

PHP Code:

$singapore_time =  //should get values from $row_Recordset1['hours'] and

//$row_Recordset1['mins']

$gmt $singapore_time - (28800);

echo 
'GMT is: '.date('H:i'$gmt); 
As you can see I want to get the correct time format which will be stored in $singapore_time variable given the following values:
$row_Recordset1['hours']
$row_Recordset1['mins']

Can anyone please help me with this ?
Reply With Quote