Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

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

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
sarika1977
Asked:
sarika1977
  • 3
1 Solution
 
manav_mathurCommented:
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
 
manav_mathurCommented:
or set

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

Manav
0
 
manav_mathurCommented:
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
 
kanduraCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now