469,304 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

MMYYYY - datestamp

How would I find the month and year from something with a datestamp of
1078801582? (The day does not matter)
Jul 19 '05 #1
5 5988
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
Jul 19 '05 #2
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
Jul 19 '05 #3
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
Jul 19 '05 #4
$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" <ze****@gmail.com> wrote in message
news:x1*******************@news20.bellglobal.com.. .
How would I find the month and year from something with a datestamp of
1078801582? (The day does not matter)

Jul 19 '05 #5
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
Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bert Sierra | last post: by
reply views Thread by Jeff York | last post: by
8 posts views Thread by Daniele Baroncelli | last post: by
1 post views Thread by drec | last post: by
17 posts views Thread by Phil M | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.