datetime - convert localtime to utc time in perl -
i calculated time 10 minutes before current time. need convert utc time using perl script. please help. have used code :-
my $dt = time(); $dt = $dt - 10 * 60; # 10 minutes before of current date.
i want time in format :-
2014-08-14t05:52:16.
you should consider using strftime
, available via posix module. see:
perldoc posix
for information on module, and
man strftime
for information on function. use e.g.
#!/usr/bin/perl -w use strict; use warnings; use posix qw(strftime); $dt = time(); $dt -= 10 * 60; print "datetime: ", strftime('%y-%m-%dt%h:%m:%s.', gmtime($dt)), "\n";
Comments
Post a Comment