Results 1 to 5 of 5

Thread: Date Conversion Problem

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Date Conversion Problem

    Hey..guys!I need to transfer a string to date format.The script having error said that call to a member function parse() on a non-object.Thanks for your help...

    PHP Code:
    $reserve_date mysql_real_escape_string($_GET['selected_date']); 
        
    $reserve_time mysql_real_escape_string($_GET['showtime']); 
           
        
    $input_format date('dd.MM.yyyy HH:mm:ss'); //Europe standard
        
    $output_format date('yyyy-MM-dd HH:mm:ss'); //mySql standard
        
    $input_date $reserve_date " " $reserve_time;
        
    $date $input_format->parse($input_date); 

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    that means that $input_format is not an object. which is correct, in the code you posted it is just a variable.
    what are you trying to do with the date (eg.. what's the parse() method supposed to accomplish)

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am trying to use parse() to parse $input_date which is string to format of date,$date, according to $input_format that I defined

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    although its still done by even websters dictionary, it's usually not good practice to use the word in the definition.

    you are trying to convert some string into a date format and save it to that $date variable? well that is what the date() function is for. if that isnt what you were trying to do, well then im sorry and can you please explain again? without using the word lol

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You are using date's format parameters incorrectly.

    Each letter represents a single specific key to a result.

    yyyy will repeat the year 4 times, and mm will repeat the month twice.

    review the chart on php.net (search for 'date') for full info.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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