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. 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. 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 Link to comment https://forums.phpfreaks.com/topic/15276-php-time-and-date/#findComment-61744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.