Re: "What date/time was it 7 hours ago"?
| From: | Michael Kimsal | Date: | Mon, 15 Apr 2002 15:31:43 +0000 |
| Subject: | Re: "What date/time was it 7 hours ago"? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93024@lists.php.net to get a copy of this message | ||
Torkil Johnsen wrote:
"What date/time was it 7 hours ago"? I'm just trying to make a log using mysql/php This log is kinda supposed to show the time, local to the user. So I store datetime on the format YYYY-MM-DD HH:MM:SS in a datetime field. Using the php date function to get the date. This will store the time that right then ON THE SERVER. Now, when fetching data from the mysql table, I want to display what the time WAS, LOCALLY (where I'm at, not the server) when the log entry was made. So. How do I make a function that takes in YYYY-MM-DD HH:MM:SS and spits out the YYYY-MM-DD HH:MM:SS minus... for instance, 7 hours? "What date/time was it 7 hours ago"?function timebefore($time,$hours=7) { $x = strtotime($time) - ($hours * 3600); return date("Y-m-d H:i:s A",$x); } Michael Kimsal http://www.phphelpdesk.com Guaranteed PHP support when you need it 734-480-9961