Hi, I've studied the date() function page on php.net, and searched for a solution, but to no avail, although I reckon there's an easy answer to this question:
How do I subtract 2 hours from the following date timestamp?
$day = date("d ");
$year = date(" Y, H:i:s");
return $month.$day.$year;
The MySQL field is set to a timestamp of NOW(). The server is running PHP4.x so the new PHP 5 function for setting a certain timezone is not possible.
Thanks in advance!
Changing server time
Moderator: General Moderators
I ran through the halls shouting for joy when I found strtotime(). You can use it like so:
Code: Select all
$timestamp = time();
$less_2_hours = strtotime('-2 hours',$timestamp);Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Or just
Code: Select all
$timestamp = time();
$less_two_hours = $timestamp - 6400;Unless those two hours span a transfer between standard and daylight saving timeJenk wrote:Or justCode: Select all
$timestamp = time(); $less_two_hours = $timestamp - 6400;
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.