CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [TheBigAmbulance] Time Conversion Issue: Edit Log



Chris Charley
User

Jul 20, 2012, 6:29 PM


Views: 5858
Re: [TheBigAmbulance] Time Conversion Issue

Maybe you could get an idea from this - it uses Date::Parse for the various times and their timezones. (My localtime zone is EDT, New York).

Code
 #!/usr/bin/perl 
use strict;
use warnings;
use POSIX qw/ strftime /;
use Date::Parse qw/ str2time /;

my @array = (
"2012-07-06T03:23:56.000Z",
"2012-07-06T03:33:53.000Z",
"2012-07-06T03:36:48.000Z",
"2012-07-06T03:36:08.000Z",
"2012-07-06T03:35:25.000Z",
"2012-06-29T12:50:12-04:00",
"2012-06-29T11:20:53-04:00",
"2012-07-01T00:59:48-04:00",
"2012-07-01T00:59:44-04:00",
"2012-07-01T07:51:14-04:00",
"2012-07-01T10:00:31-04:00",
"2012-07-01T17:20:13-04:00",
"2012-07-01T21:19:26-04:00",
"2012-07-01T22:01:10-04:00",
"2012-07-02T13:21:11-04:00",
"2012-07-02T11:15:02-04:00",
"2012-07-02T18:10:37-04:00",
"2012-07-04T23:55:51-04:00",
"2012-07-04T22:19:59-04:00",
"2012-07-05T17:47:26-04:00",
"2012-07-06T08:35:53-04:00",
"2012-07-06T13:04:17-04:00",
"2012-07-06T17:56:16-04:00",
"2012-07-07T17:52:40-04:00",
"2012-07-09T07:46:29-04:00",
"2012-07-01T18:14:39Z",
"2012-07-09T11:06:50Z",
"2012-06-29T16:44:37Z",
"2012-07-02T19:20:29Z"
);

for my $dt (@array) { # for my $datetime
printf "RAW - %s\tLocal - %s\n",
substr($dt, 0, 19),
strftime("%Y-%m-%d %I:%M:%S %p", localtime(str2time($dt)));
}

__END__
C:\Old_Data\perlp>perl t3.pl
RAW - 2012-07-06T03:23:56 Local - 2012-07-05 11:23:56 PM
RAW - 2012-07-06T03:33:53 Local - 2012-07-05 11:33:53 PM
RAW - 2012-07-06T03:36:48 Local - 2012-07-05 11:36:48 PM
RAW - 2012-07-06T03:36:08 Local - 2012-07-05 11:36:08 PM
RAW - 2012-07-06T03:35:25 Local - 2012-07-05 11:35:25 PM
RAW - 2012-06-29T12:50:12 Local - 2012-06-29 12:50:12 PM
RAW - 2012-06-29T11:20:53 Local - 2012-06-29 11:20:53 AM
RAW - 2012-07-01T00:59:48 Local - 2012-07-01 12:59:48 AM
RAW - 2012-07-01T00:59:44 Local - 2012-07-01 12:59:44 AM
RAW - 2012-07-01T07:51:14 Local - 2012-07-01 07:51:14 AM
RAW - 2012-07-01T10:00:31 Local - 2012-07-01 10:00:31 AM
RAW - 2012-07-01T17:20:13 Local - 2012-07-01 05:20:13 PM
RAW - 2012-07-01T21:19:26 Local - 2012-07-01 09:19:26 PM
RAW - 2012-07-01T22:01:10 Local - 2012-07-01 10:01:10 PM
RAW - 2012-07-02T13:21:11 Local - 2012-07-02 01:21:11 PM
RAW - 2012-07-02T11:15:02 Local - 2012-07-02 11:15:02 AM
RAW - 2012-07-02T18:10:37 Local - 2012-07-02 06:10:37 PM
RAW - 2012-07-04T23:55:51 Local - 2012-07-04 11:55:51 PM
RAW - 2012-07-04T22:19:59 Local - 2012-07-04 10:19:59 PM
RAW - 2012-07-05T17:47:26 Local - 2012-07-05 05:47:26 PM
RAW - 2012-07-06T08:35:53 Local - 2012-07-06 08:35:53 AM
RAW - 2012-07-06T13:04:17 Local - 2012-07-06 01:04:17 PM
RAW - 2012-07-06T17:56:16 Local - 2012-07-06 05:56:16 PM
RAW - 2012-07-07T17:52:40 Local - 2012-07-07 05:52:40 PM
RAW - 2012-07-09T07:46:29 Local - 2012-07-09 07:46:29 AM
RAW - 2012-07-01T18:14:39 Local - 2012-07-01 02:14:39 PM
RAW - 2012-07-09T11:06:50 Local - 2012-07-09 07:06:50 AM
RAW - 2012-06-29T16:44:37 Local - 2012-06-29 12:44:37 PM
RAW - 2012-07-02T19:20:29 Local - 2012-07-02 03:20:29 PM



(This post was edited by Chris Charley on Jul 20, 2012, 9:02 PM)


Edit Log:
Post edited by Chris Charley (User) on Jul 20, 2012, 9:02 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives