[Cascavel-pm] OFF- DUVIDA data do TimeStamp

Nelson Ferraz nferraz em gmail.com
Quarta Maio 17 04:35:28 PDT 2006


Patty Silva wrote:
> Pessoal, extrai a data usando o MYSQL UNIX_TIMESTAMP(), como eu faco 
> para visualizar qual data corresponde a essa saida
> ex: ele me gera assim: 1142996400 , quero vizualizar essa data no 
> formato yyyy-mm-dd hh ;) tem como?

Procurando no Google:

http://www.google.com/search?q=mysql+unix_timestamp

Primeiro resultado:

FROM_UNIXTIME(unix_timestamp), FROM_UNIXTIME(unix_timestamp,format)

Returns a representation of the unix_timestamp argument as a value in 
'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the 
function is used in a string or numeric context. unix_timestamp is an 
internal timestamp value such as is produced by the UNIX_TIMESTAMP() 
function.

If format is given, the result is formatted according to the format 
string, which is used the same way as listed in the entry for the 
DATE_FORMAT() function.

mysql> SELECT FROM_UNIXTIME(875996580);
         -> '1997-10-04 22:23:00'
mysql> SELECT FROM_UNIXTIME(875996580) + 0;
         -> 19971004222300
mysql> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),
     ->                      '%Y %D %M %h:%i:%s %x');
         -> '2003 6th August 06:22:58 2003'

Note: If you use UNIX_TIMESTAMP() and FROM_UNIXTIME() to convert between 
TIMESTAMP values and Unix timestamp values, the conversion is lossy 
because the mapping is not one-to-one in both directions. For details, 
see the description of the UNIX_TIMESTAMP() function.

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html


Mais detalhes sobre a lista de discussão Cascavel-pm