Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl (http://www.velocityreviews.com/forums/f17-perl.html)
-   -   MMYYYY - datestamp (http://www.velocityreviews.com/forums/t25373-mmyyyy-datestamp.html)

Zee Zop 09-20-2004 05:01 PM

MMYYYY - datestamp
 
How would I find the month and year from something with a datestamp of
1078801582? (The day does not matter)



Gunnar Hjalmarsson 09-20-2004 06:02 PM

Re: MMYYYY - datestamp
 
Zee Zop wrote:
> How would I find the month and year from something with a datestamp
> of 1078801582? (The day does not matter)


perldoc -f localtime
perldoc -f gmtime

Next time, post to comp.lang.perl.misc instead. This group is defunct.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jürgen Exner 09-20-2004 07:05 PM

Re: MMYYYY - datestamp
 
Zee Zop wrote:
> How would I find the month and year from something with a datestamp of
> 1078801582? (The day does not matter)


Is this from the Romulan or the Klingon calendar?

jue



Joe Smith 09-21-2004 06:37 PM

Re: MMYYYY - datestamp
 
Zee Zop wrote:

> How would I find the month and year from something with a datestamp of
> 1078801582?


You want localtime() in list context. Be mindfull of $month+1 and $year+1900.

Using localtime() in scalar context is also handy:
perl -le 'print scalar localtime 1078801582'

-Joe

Dan van Ginhoven 10-01-2004 04:42 PM

Re: MMYYYY - datestamp
 
$MYTIMESTAMP = "1095967319";

($ss,$mi,$hh,$dd,$mm,$yy ,$wday,$ddd ,$isdst) = localtime($MYTIMESTAMP);
$yy+=1900;
$mm+=1;
$mm = substr("0".$mm,-2,2);
$dd = substr("0".$dd,-2,2);
$hh = substr("0".$hh,-2,2);
$mi = substr("0".$mi,-2,2);
$ss = substr("0".$ss,-2,2);
print "$yy-$mm-$dd $hh:$mi:$ss";


"Zee Zop" <zeezop@gmail.com> wrote in message
news:x1E3d.8097$bL1.376379@news20.bellglobal.com.. .
> How would I find the month and year from something with a datestamp of
> 1078801582? (The day does not matter)
>
>




Gunnar Hjalmarsson 10-01-2004 08:48 PM

Re: MMYYYY - datestamp
 
Dan van Ginhoven wrote:
> $MYTIMESTAMP = "1095967319";
>
> ($ss,$mi,$hh,$dd,$mm,$yy ,$wday,$ddd ,$isdst) = localtime($MYTIMESTAMP);
> $yy+=1900;
> $mm+=1;
> $mm = substr("0".$mm,-2,2);
> $dd = substr("0".$dd,-2,2);
> $hh = substr("0".$hh,-2,2);
> $mi = substr("0".$mi,-2,2);
> $ss = substr("0".$ss,-2,2);
> print "$yy-$mm-$dd $hh:$mi:$ss";


What kind of grudge do you have against the sprintf() function? ;-)

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


All times are GMT. The time now is 04:25 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.