rupam_jaiswal Posted December 26, 2009 Share Posted December 26, 2009 Hi, I am using php gmdate(). Now I am entering all dates in my dbase using gmdate("Y-m-d H:i:s") I want 1 hr before datetime. So am using like gmdate("Y-m-d H:i:s", mktime(gmdate("H")-$hrs, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"))); where $hr = 1 When I echo current date i,e $date = gmdate('Y-m-d H:i:s'); echo "<br/>current date is $date"; its 2009-12-27 03:54:08 and when echo my code of getting 1 hr before $date1 = gmdate("Y-m-d H:i:s", mktime(gmdate("H")-1, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"))); its 2009-12-26 02:54:08 difference between these 2 days is 1 day and not 1 hr. I want 1 hr before datetime to be 2009-12-27 02:54:08 Can please anybody help. Thanks in advance Regards Quote Link to comment https://forums.phpfreaks.com/topic/186368-gmdate-want-1-hr-before-time/ Share on other sites More sharing options...
vinpkl Posted December 26, 2009 Share Posted December 26, 2009 try this <?php $date1 = gmdate("Y-m-d H:i:s", mktime(gmdate("H"), gmdate("i")-60, gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"))); echo $date1; ?> vineet Quote Link to comment https://forums.phpfreaks.com/topic/186368-gmdate-want-1-hr-before-time/#findComment-984177 Share on other sites More sharing options...
rupam_jaiswal Posted December 26, 2009 Author Share Posted December 26, 2009 Thanx for your help. Am using gmmktime Quote Link to comment https://forums.phpfreaks.com/topic/186368-gmdate-want-1-hr-before-time/#findComment-984199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.