?
Solved

Date::Manip - Date Conversion for GMT to other timezone (say IST)

Posted on 2005-03-04
4
Medium Priority
?
1,145 Views
Last Modified: 2008-03-03
use Date::Manip;
 printf "%s\n", &UnixDate("Mar  3 2005  3:16:20:000AM","%H:%M:%S");

--> Displays: 03:16:20

The time "Mar  3 2005  3:16:20:000AM" is in GMT format.
I need to display it in IST (GMT + 5.5 Hours)

Please help.
0
Comment
Question by:sarika1977
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Expert Comment

by:manav_mathur
ID: 13459331
try

printf "%s\n", &UnixDate("Mar  3 2005  3:16:20:000AM IST","%H:%M:%S");

I dont have Date::Manip but help shows that oyu can affix time zone to the end of it

Manav
0
 
LVL 16

Expert Comment

by:manav_mathur
ID: 13459387
or set

$main::TZ = 'IST' ;
in your program

Manav
0
 
LVL 16

Accepted Solution

by:
manav_mathur earned 500 total points
ID: 13459396
e.g to convert GMT time to IST time

use Date::Manip;
$main::TZ = 'IST' ;
printf "%s\n", &UnixDate("Mar  3 2005  3:16:20:000AM GMT","%H:%M:%S");

Manav
0
 
LVL 18

Expert Comment

by:kandura
ID: 13461018
I'd use DateTime and related modules:

use DateTime;
use DateTime::Format::DateManip;

my $dt = DateTime::Format::DateManip->parse_datetime("Mar  3 2005  3:16:20:000AM");

$dt->set_time_zone('Asia/Calcutta');
print $dt->hms;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question