Results 1 to 6 of 6

Thread: Perl Date Formating

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Perl Date Formating

    Im kinda lost, I need all of the dates to be formated to a Postgres happy state. Can you help?


    Code I have been trying to work with (its lying.. not php):
    PHP Code:
            if($format eq "MM-DD-YYYY")
            {
                if(
    $data =~ /-/){
                    (
    $month,$day,$year) = split("-",$data) if $data =~ /-/;
                    (
    $month,$day,$year) = split("/",$data) if $data =~ /\//;
                    
    $month "01" if ($month == 0);
                    
    $year "2000" if ($year == 0);
                    
    $day "01" if ($day == 0);
                    
    $data="$year-$month-$day";
                } else {
                    
    #try to form a correct date
                    
    if(length($date) == || length($date) == 6) {
                        
    #2004-01-01 (20040101)
                        
    $date =~ s/\d{2}\d{2}\d{4}/\d{2}-\d{2}-\d{4}/e;
                    
                    }

                } 
    Thanks!!
    Last edited by Evan; Jan 30th, 2004 at 07:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width