Re: [PHP] "What date/time was it 7 hours ago"?

2002-04-15 Thread Richard Emery

If you are using mysql, you can perform the calculations in mysql during the
SELECT, such as:
SELECT date_field - INTERVAL 7 HOUR FROM my_table;

- Original Message -
On Monday, April 15, 2002, at 09:50  AM, 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 -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 -MM-DD HH:MM:SS and
> spits out
> the -MM-DD HH:MM:SS minus... for instance, 7 hours?
>
> "What date/time was it 7 hours ago"?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] "What date/time was it 7 hours ago"?

2002-04-15 Thread Steve Cayford

You could convert it to a timestamp using strtotime(), subtract 7*60*60, 
then convert it back to a string with strftime().

-Steve

On Monday, April 15, 2002, at 09:50  AM, 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 -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 -MM-DD HH:MM:SS and 
> spits out
> the -MM-DD HH:MM:SS minus... for instance, 7 hours?
>
> "What date/time was it 7 hours ago"?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php