Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Date and Time

by arrow (Friar)
on Dec 03, 2002 at 00:30 UTC ( [id://217093]=note: print w/replies, xml ) Need Help??


in reply to Date and Time

Yeah, SuperCruncher and others are right, I should have investigated further. Sorry for seeming lazy (maybe I was :-)), but here's my code:
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday, +my $isdst)=localtime(time); my $month1 = $mon+1; my $year1 = $year+1900; if ($mday == 1 && $month1 == 2) { $mday = 28; } elsif ($mday == 1 && $month1 == 4) { $mday = 30; } elsif ($mday == 1 && $month1 == 6) { $mday = 30; } elsif ($mday == 1 && $month1 == 9) { $mday = 30; } elsif ($mday == 1 && $month1 == 11) { $mday = 30; } else { $mday--; } my $date1 = "$month1\/$mday\/$year1";


Just Another Perl Wannabe

Replies are listed 'Best First'.
Re: Re: Date and Time
by DamnDirtyApe (Curate) on Dec 03, 2002 at 02:12 UTC

    Your adjustments are not necessary here. Assuming the only issue here is the time zone difference, try consolidating your code into something like the following:

    my $server_tz = 0 ; # GMT my $client_tz = -8 ; # PST my $offset = $client_tz - $server_tz ; my @t = localtime( time + ( $offset * 3600 ) ) ; my $date = sprintf "%d/%d/%d", $t[4] + 1, $t[3], $t[5] + 1900 ;

    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
    
                --Friedrich Nietzsche

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://217093]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-26 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found