Re: days of the week, time calculations
| From: | Chris Adams | Date: | Mon, 10 Jul 2000 19:20:53 +0000 |
| Subject: | Re: days of the week, time calculations | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5790@lists.php.net to get a copy of this message | ||
> I need to convert MySQL's timestamp into a format
> that I can use for calculating the number of seconds
> between two date/times. I also need to be able to
> determine what day of the week a given timestamp
> is.
SELECT UNIX_TIMESTAMP(MyDateColumn) FROM Table
Unix timestamps are stored in seconds, so you can do that sort of work with
simple subtractions. This also allows you to use all of PHP's built-in date
formatting functions (e.g. date()) to format the output. As an example,
date('D', time()) will display a 3 letter day of the week ('Mon',
'Tue',
etc.), while 'l' will give the long date ('Monday', 'Tuesday') and
'w' will
give the numeric day of the week.
It might also be useful that the date functions can use the built-in locale
settings, which could make it easier to display things like the name of days
or months for multiple countries/languages.