Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > MMYYYY - datestamp

Reply
Thread Tools

MMYYYY - datestamp

 
 
Zee Zop
Guest
Posts: n/a
 
      09-20-2004
How would I find the month and year from something with a datestamp of
1078801582? (The day does not matter)


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      09-20-2004
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
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      09-20-2004
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


 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      09-21-2004
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
 
Reply With Quote
 
Dan van Ginhoven
Guest
Posts: n/a
 
      10-01-2004
$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" <> wrote in message
news1E3d.8097$.. .
> How would I find the month and year from something with a datestamp of
> 1078801582? (The day does not matter)
>
>



 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      10-01-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datestamp? Valerie Computer Support 2 12-29-2007 02:31 PM
Datestamp on Olympus Stylus mju 720/725/770 sw The One Digital Photography 2 07-20-2007 05:47 AM
display datestamp in HTML Phil M Perl Misc 9 05-18-2007 06:13 PM
Removing Datestamp bilvihur@localnet.com Digital Photography 6 08-11-2005 10:21 AM
How to get prints with a datestamp on them Michael Poole Digital Photography 2 08-01-2005 12:52 AM



Advertisments