Jump to content

Archived

This topic is now archived and is closed to further replies.

tomjones

php time and "date"

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Look at the strtotime() function http://www.php.net/strtotime

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

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.