tomjones Posted July 21, 2006 Share Posted July 21, 2006 Hi,I have been experimenting with date and getdate. I would like to have a variable whose value is the current date, minus one hour. Could someone provide some insight into how to achieve this.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/15276-php-time-and-date/ Share on other sites More sharing options...
wildteen88 Posted July 21, 2006 Share Posted July 21, 2006 Something like this:[code=php:0]echo date("h:m:s", time()-3600);[/code]time returns a unix timestamp, so take 3,600 secounds from the timestamp will take 1hour of the current time. Quote Link to comment https://forums.phpfreaks.com/topic/15276-php-time-and-date/#findComment-61742 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 Look at the strtotime() function http://www.php.net/strtotime[code]<?php $x = date('Y-m-d G:i',strtotime('-1 hour')); ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/15276-php-time-and-date/#findComment-61744 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.