var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
[PHP] Converting a time
I have various times stored in my MySQL database in the format HH : MM : SS.
To allow for my users' timezones I basically wish to take 2 hours off the time.
For example, 16:18:02 would become 14:18:02.
I've searched endlessely and can only find how to do this with dates. Is there anybody who can help me out?!
Many thanks in advance!
this first converts to unix time stamp; from there you can change to time.
$t = strtotime('-2 hour', strtotime('16:18:02'));
echo date('G:i:s', $t);
Last edited by orbitz; 09-14-2006 at 01:12 PM.
just play with it until it works fine Oh well orbitz beat me to it.
$test = '16:18:02';
$timestamp = strtotime($test);
$timestamp = date('i:s', $timestamp);
If you use mysql >= 4.1 you should have subtime() and addtime()
select subtime( '11:53:14' , '2:0:0') ; should return 9:53:14
So you can do: select subtime( my_time_field , '2:0:0') AS some_time ....