Re: Timestamps
| From: | php3 at developersdesk dot com | Date: | Wed, 21 Jun 2000 04:38:22 +0000 |
| Subject: | Re: Timestamps | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-2433@lists.php.net to get a copy of this message | ||
Addressed to: "Simon Berg" <spam@swipnet.se>
php-general@lists.php.net
** Reply to note from "Simon Berg" <spam@swipnet.se> Wed, 21 Jun 2000 00:50:12 +0200
>
> Hello, I need to convert a mysql timestamp (200006210000) to a unix
> timestamp (seconds from 1970), anyone know how to do it?
>
From section 7.3.11 Date and time functions of the MySQL manual:
UNIX_TIMESTAMP()
UNIX_TIMESTAMP(date)
If called with no argument, returns a Unix timestamp (seconds
since '1970-01-01 00:00:00' GMT). If UNIX_TIMESTAMP() is called
with a date argument, it returns the value of the argument as
seconds since '1970-01-01 00:00:00' GMT. date may be a DATE
string, a DATETIME string, a TIMESTAMP, or a number in the
format YYMMDD or YYYYMMDD in local time.
mysql> select UNIX_TIMESTAMP();
-> 882226357
mysql> select UNIX_TIMESTAMP('1997-10-04 22:23:00');
-> 875996580
When UNIX_TIMESTAMP is used on a TIMESTAMP column, the function
will receive the value directly, with no implicit
"string-to-unix-timestamp" conversion.
There is a ton of good information in the MySQL manual.
http://web.mysql.com/Manual_chapter/manual_toc.html
I'd suggest you spend some time reading through at least sections 9, 5,
6, and 7 in that order... Just having an idea what is in there can
save you an incredible amount of time.
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com