Jump to content


Photo

php time and "date"


  • Please log in to reply
2 replies to this topic

#1 tomjones

tomjones
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 21 July 2006 - 05:31 PM

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.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 July 2006 - 05:35 PM

Something like this:
echo date("h:m:s", time()-3600);

time returns a unix timestamp, so take 3,600 secounds from the timestamp will take 1hour of the current time.

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 July 2006 - 05:37 PM

Look at the strtotime() function http://www.php.net/strtotime

<?php $x = date('Y-m-d G:i',strtotime('-1 hour')); ?>

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users