godsent Posted February 3, 2011 Share Posted February 3, 2011 To get current date and time I use: $date = date("d-M-Y h:i:s"); But how can I get date and time which was before 5 minutes. Quote Link to comment https://forums.phpfreaks.com/topic/226552-php-get-time-before-5-minutes/ Share on other sites More sharing options...
trq Posted February 3, 2011 Share Posted February 3, 2011 before 5 minutes? That makes NO sense. Quote Link to comment https://forums.phpfreaks.com/topic/226552-php-get-time-before-5-minutes/#findComment-1169331 Share on other sites More sharing options...
godsent Posted February 3, 2011 Author Share Posted February 3, 2011 For example if now is: 03-Jan-2011 10:33:56 The script would show: 03-Jan-2011 10:28:56 Quote Link to comment https://forums.phpfreaks.com/topic/226552-php-get-time-before-5-minutes/#findComment-1169338 Share on other sites More sharing options...
jamesxg1 Posted February 3, 2011 Share Posted February 3, 2011 $minutes = date('i') - 5; $before = date("d-M-Y h:") . $minutes . date(":s"); James. Quote Link to comment https://forums.phpfreaks.com/topic/226552-php-get-time-before-5-minutes/#findComment-1169343 Share on other sites More sharing options...
trq Posted February 3, 2011 Share Posted February 3, 2011 That would be '5 minutes prior to' not 'before 5 minutes'. $date = date("d-M-Y h:i:s", strtotime('-5 minutes')); Quote Link to comment https://forums.phpfreaks.com/topic/226552-php-get-time-before-5-minutes/#findComment-1169344 Share on other sites More sharing options...
charles07 Posted December 2, 2011 Share Posted December 2, 2011 thanks buddy, your answer worked like a charm, thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/226552-php-get-time-before-5-minutes/#findComment-1293338 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.