Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Dates and time.

by xqus (Initiate)
on Jun 11, 2000 at 00:48 UTC ( #17530=perlquestion: print w/replies, xml ) Need Help??

xqus has asked for the wisdom of the Perl Monks concerning the following question:

Hi!! I have a number 960662500.
That is the time of next update to a page.
Is it a way i can print this to that page in a normal way.
eg, May 15 2000 ??


Replies are listed 'Best First'.
Re: Dates and time.
by plaid (Chaplain) on Jun 11, 2000 at 01:00 UTC
    Take a look at several methods listed in the Q&A here.
(jcwren) RE: Dates and time.
by jcwren (Prior) on Jun 11, 2000 at 00:54 UTC
    You can do this:  print scalar localtime (960662500));which will yield 'Sat Jun 10 14:41:40 2000'

Re: Dates and time.
by Zoogie (Curate) on Jun 11, 2000 at 01:03 UTC
    Use localtime:    print scalar localtime(960662500); If you want it in "MMM dd YYYY" format, you can use:
    use POSIX qw(strftime); print(strftime("%b %d %Y",localtime(960662500)));
RE: Dates and time.
by Adam (Vicar) on Jun 11, 2000 at 04:08 UTC
    You can use the default format returned by scalar localtime or you can do your own. Localtime is slick in that it converts the input (non-leap seconds of the epoch... usually from Jan 1 1970) into an array of useful data. You can then access that array and use the info any way you want. I definately recomend viewing the man page but I'll give you an example:
    @info = localtime( $time ); # You provide $time, or get it from time() $stamp = (Jan, Feb, Mar, Apr, May, June, July, Aug, Sept, Oct, Nov, De +c)[$info[4]]; $stamp .= ' '; $stamp .= $info[3]; $stamp .= ' '; $stamp .= 1900 + $info[5]; print $stamp;
    This gives the format you suggested of Month DD YYYY

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://17530]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-05-18 21:56 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (71 votes). Check out past polls.