Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Getting started with DateTime

by monsterzero (Monk)
on Jan 16, 2004 at 16:59 UTC ( #321831=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
         use strict;
         use warnings;
    ...
                              minute     => 0,
                              second     => 0,
                               );
    
  2. or download this
         my $dt2 = DateTime->now(time_zone=>'local');
         my $dt3 = DateTime->today(time_zone=>'local');
    
  3. or download this
         print $dt1->ymd('-'); # produces 2003-08-20
         print $dt1->mdy('-'); # produces 08-20-2003
         print $dt1->datetime(); # produces 2003-08-20T00:00:00
    
  4. or download this
        my $dt1 = DateTime->new( year => 2003, 
                                 month => 8, day => 26,
                                 hour => 21, 
                                 time_zone => 'America/Chicago' );
    
  5. or download this
        $dt2 = $dt1->clone->set_time_zone( 'Europe/Helsinki' );
        print $dt2->datetime, "\n";
    
  6. or download this
         my $dt1 = DateTime-> new (
                         year =>'1998',
    ...
    
         $dt1->add(hours =>10);
         print $dt1->datetime ,"\n";
    
  7. or download this
         use strict;
         use warnings;
    ...
         my $dt_class = 'DateTime::Format::HTTP';
         my $dt = $dt_class->parse_datetime($date);
         print $dt_class->format_datetime($dt);
    
  8. or download this
    use strict;
    use warnings;
    ...
    DateTime::Format::ISO8601->parse_datetime( $_[1]) } },
        ] }
      );
    
  9. or download this
         my $dt = DateTime-> new(year => 2002,
                            month=> 8,
    ...
                           );
    
         my $cmp = DateTime->compare($dt, $dt2);
    
  10. or download this
         if ($dt > $dt2) {do ....;}
         elsif($dt == $dt2) {do something else;}
         elsif($dt < $dt2) {do still something else...;}
    
  11. or download this
       my $dt1 = DateTime->now();
       my $dt2 = $dt1->clone->subtract( weeks => 1);
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2016-10-01 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (7 votes). Check out past polls.