in reply to UnixDate - getting a different date

Yep, it's locale. I'm getting different results, depending on TZ value. But changing TZ after I've called UnixDate once doesn't have any effect.
#!/usr/bin/perl use strict; use warnings; use Date::Manip; use Data::Dumper; my $tot_start_date = '2008-06-27 17:37:11 +0000'; my $tot_end_date = '2008-09-29 04:02:18 +0000'; my $beta_start_date = '2008-09-29 04:02:18 +0000'; my $beta_end_date = '2009-01-07 00:00:00 -0800'; #$ENV{TZ}='America/Montreal'; $ENV{TZ}='UTC'; $tot_start_date = UnixDate($tot_start_date,"%Y-%m-%d"); $tot_end_date = UnixDate($tot_end_date,"%Y-%m-%d"); $beta_start_date = UnixDate($beta_start_date,"%Y-%m-%d"); $beta_end_date = UnixDate($beta_end_date,"%Y-%m-%d"); print Dumper $tot_start_date; print Dumper $tot_end_date; print Dumper $beta_start_date; print Dumper $beta_end_date; __END__ output for Montreal: $VAR1 = '2008-06-27'; $VAR1 = '2008-09-28'; $VAR1 = '2008-09-28'; $VAR1 = '2009-01-07'; output for UTC: $VAR1 = '2008-06-27'; $VAR1 = '2008-09-29'; $VAR1 = '2008-09-29'; $VAR1 = '2009-01-07';

Replies are listed 'Best First'.
Re^2: UnixDate - getting a different date
by d-evil (Novice) on Dec 24, 2008 at 14:28 UTC
    ^^ Even if i set timezone, i am getting a different dates in some cases. Is there any way or knob to discard the time in the date with the UnixDate
      d-evil:

      If you're not going to use a module, the best knob is to use functions that are compatible with each other (i.e., use functions that assume UTC only or the local time zone only, and don't mix them).

      But the better knob would be to not worry about it at all. Instead, use one of the Date::* modules from CPAN to do all the grunt work.

      Update: By the way, I think you wanted to use <code> tags for (your question) your question, rather than <center>. You might go back to your node and fix it...

      ...roboticus

      Update: The [node] in parenthesis is present only so that node "id vs. node oddity" makes sense.