I have date in this format 2011-04-24T05:59:49.000Z I need date/time exact seven hours before this date/time. How I can do this. please help.
You can try $temp_timestamp = strtotime("2011-04-24T05:59:49.000Z"); $seven_hours_ago = strtotime("-7 hour", $temp_timestamp); echo Date("Y-m-d\TH:i:s\Z", $seven_hours_ago); Little John
This might work (not tested): $ts = strtotime("2011-04-24T05:59:49.000Z"); echo sprintf( "The time was %s; 7 hours ago it was %s", gmdate("Y-m-d H:i:s", $ts), gmdate("Y-m-d H:i:s", $ts - 7 * 60 * 60) ); PHP:
Thanks littlejohn199 and ap2010 for your response. I have tested littlejohn199's code and it's working fine. Rep to you both.