Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Print time in Date"T"time+Gmtoffset

by frozenwithjoy (Priest)
on Apr 01, 2014 at 06:38 UTC ( [id://1080488]=note: print w/replies, xml ) Need Help??


in reply to Print time in Date"T"time+Gmtoffset

Is the colon required in the offset for your purposes? If not:

perl -E ' use POSIX; say strftime "%Y-%m-%dT%H:%M:%S%z", localtime(); ' 2014-03-31T23:37:59-0700

If you want the colon and no zero-padding, you could grab the offset by itself (strftime "%z", localtime();), throw a colon in it and drop the leftmost digit if it is 0. Or there might be an easier way.

Replies are listed 'Best First'.
Re^2: Print time in Date"T"time+Gmtoffset
by ikegami (Patriarch) on Apr 01, 2014 at 14:17 UTC
    Allowing the leading zero to be dropped would be a bad choice of format as it would no longer be an iso8601 timestamp. (Adding a colon is fine.)
Re^2: Print time in Date"T"time+Gmtoffset
by techman2006 (Beadle) on Apr 01, 2014 at 07:00 UTC

    Thanks but I need a colon in timezone as need to put it in a xml file which understand that notation only.

      then do it in two steps :) second step being adding colon to timezone

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1080488]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-24 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found