[linux] operacie s datumom v perle

Jan Andrejkovic andrejkj na hornad.fei.tuke.sk
Úterý Květen 1 01:13:10 CEST 2001


Ahoj,

On Mon, 30 Apr 2001, Rasto Fuko wrote:

> Sorry je to trochu off-topic
> 
> s perlom mam velmi malo skusenosti.
> Je mozne premennu typu timestamp ziskanu z postgres databazy
> "2001-04-21 15:54:11+02" previest na tvar aky udava premenna time v 
> perle (pocet s od r. 1970)?
> Poterbujem totiz v perl skripte porovnavat aktualny datum a datum zadany v 
> postgres tabulke
> alebo to mezem spravit aj inac?
> dik
> Rasto

Neviem ako postgres, ale mySQL ma taku funckiu: 
S pozdravom, Tofu.

`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.





Další informace o konferenci linux