Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2002
    Posts
    309

    Question Need help from a real PRO in php !!!! Weird thing whit php 4.2.2...

    Ok so i have a script that use a date come from mysql db the prob is php look like to extract it weird...

    The output should be 31.12.2002 but there IS ..2002

    came from a script like this :

    <?php
    $date= "2002-12-31";

    if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
    echo "$regs[3].$regs[2].$regs[1]";
    } else {
    echo "Invalid date format: $date";
    }

    ?>



    Whats the hell causing the date display ..2002 ?????
    thanks for any help !

  2. #2

    Question works for me

    http://home.apokalyptik.com/~apokalyptik/tmp/

    you can see a) that i'm running php 4.2.2 and b) that your script works as intended on my box

    [19:01:07][[email protected]:~/public_html/tmp]: ls -la
    total 16
    drwxr-xr-x 2 apokalyptik apokalyptik 4096 Aug 22 19:01 .
    drwxr-xr-x 25 apokalyptik apokalyptik 4096 Aug 22 18:59 ..
    -rw-r--r-- 1 apokalyptik apokalyptik 181 Aug 22 18:59 eregtime.php
    lrwxrwxrwx 1 apokalyptik apokalyptik 12 Aug 22 19:01 eregtime.phps -> eregtime.php
    -rw-r--r-- 1 apokalyptik apokalyptik 20 Aug 22 19:00 phpinfo.php
    lrwxrwxrwx 1 apokalyptik apokalyptik 11 Aug 22 19:00 phpinfo.phps -> phpinfo.php


    have you made sure of all the little simple things (e.g.: cleared your web browsers cach or your web proxies cache, etc?)

  3. #3
    Join Date
    Aug 2002
    Location
    Baltimore, Maryland
    Posts
    580

  4. #4
    Join Date
    May 2001
    Location
    Dayton, Ohio
    Posts
    4,962
    Code:
      UW PICO(tm) 4.2                            File: test.php                               Modified   
    
    <?php
    $date= "2002-12-31";
    
    if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
    echo "$regs[3].$regs[2].$regs[1]";
    } else {
    echo "Invalid date format: $date";
    }
    
    ?>
    
    
    
    
    
                                              [ Wrote 11 lines ]
    
    [email protected] [~]# php test.php
    X-Powered-By: PHP/4.2.2
    Content-type: text/html
    
    31.12.2002 
    
    [email protected] [~]#
    Works fine here...
    -Mat Sumpter
    Director, Product Engagement
    Penton Media

  5. #5
    Join Date
    Jul 2002
    Posts
    309

    Unhappy

    I dont understand why its not working on my server .. :-(


    There is some setting in PHP that can change that ???
    what i can do to make that working ??


    I'm realy lost ... :-(

  6. #6
    Join Date
    Jul 2002
    Posts
    309

    Re: works for me

    Originally posted by apokalyptik

    have you made sure of all the little simple things (e.g.: cleared your web browsers cach or your web proxies cache, etc?) [/B]

    Yea, it look like the prob come from php itself or i dunno what..... I realy dont know where to search and what i can try to correct this ... :-(((

  7. #7
    Join Date
    Jul 2001
    Location
    Wrapped in CAT5.
    Posts
    217

    Lightbulb Something to test for ...

    If your string contains a null (ASCII 0) character, ereg will not find any matches past it.

    (Helpful?)

    Dan
    Dan Esparza
    CagedTornado web services

  8. #8
    Join Date
    Jan 2002
    Location
    Melbourne, AU
    Posts
    740
    I use this little routine:
    PHP Code:
    $stringArray explode("-"$date);
    $date2 mktime(0,0,0,$stringArray[1],$stringArray[2],$stringArray[0]); 
    $zdate date("d M Y"$date2); 
    Hopefully, that will work for you.


    Lats...

  9. #9
    Join Date
    Jul 2002
    Posts
    309
    Hi,

    i have revert back my phplib.so to 4.1.1 then its working fine .... May be a compilation prob in my 4.2.2 ?

    Someone have 4.2.2 installed can you send your .configure string you have used

    i will try to recompiile it to see the result ... !

Posting Permissions

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