List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 19 2001 8:06pm
Subject:Re: unix_timestamp why 0
View as plain text  
At 9:20 PM +0200 6/19/01, Attila Soki wrote:
>hi,
>
>is this normal?
>how can i get a timestamp of dates before 1970?

The MySQL Reference Manual is your friend.

http://www.mysql.com/doc/D/a/Date_and_time_functions.html says:

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. If you give UNIX_TIMESTAMP() a
wrong or out-of-range date, it will return 0.

>
>thanks.
>
>ati
>
>
>mysql> select from_unixtime(-86400);
>+-----------------------+
>| from_unixtime(-86400) |
>+-----------------------+
>| 1969-12-31 01:00:00   |
>+-----------------------+
>1 row in set (0.00 sec)
>
>mysql> select unix_timestamp('1969-12-31 01:00:00');
>+---------------------------------------+
>| unix_timestamp('1969-12-31 01:00:00') |
>+---------------------------------------+
>|                                     0 |
>+---------------------------------------+
>1 row in set (0.00 sec)
>
>debian linux 2.2.17
>mysql 3.23.36-log
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <mysql-thread77094@stripped>
>To unsubscribe, e-mail <mysql-unsubscribe-paul=snake.net@stripped>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Paul DuBois, paul@stripped
Thread
unix_timestamp why 0Attila Soki19 Jun
  • Re: unix_timestamp why 0Paul DuBois19 Jun
    • Re: unix_timestamp why 0Attila Soki19 Jun
      • Re: unix_timestamp why 0Paul DuBois20 Jun