Gossamer Forum
Home : General : Perl Programming :

how to convert date into unixtimestamp

Quote Reply
how to convert date into unixtimestamp
hi,
i want to know the best way to get number of days between two dates which r in yyyymmdd format. also can u tell me how to convert a date into unix timestamp.
thanks
Quote Reply
Re: [sumeet] how to convert date into unixtimestamp In reply to
Hi,

Both of these depend on modules available on CPAN.

Quote:
i want to know the best way to get number of days between two dates which r in yyyymmdd format

Try:

Code:
alex@penguin alex $ perl -MDate::Manip -le 'my $d1 = ParseDate("20050101"); my $d2 = ParseDate("20040501"); print Delta_Format(DateCalc($d2, $d1), -2, "%dt")'
245.000000
alex@penguin alex $

Quote:
also can u tell me how to convert a date into unix timestamp

Try:

Code:
alex@penguin alex $ perl -MTime::Local -le 'my @date = localtime; print timelocal(@date)'
1124241673
alex@penguin alex $

Cheers,

Alex
--
Gossamer Threads Inc.