View Full Version : Date Conversion Problem

10-09-2007, 02:14 PM
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...

$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);

10-09-2007, 02:26 PM
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)

10-09-2007, 02:38 PM
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

10-09-2007, 02:47 PM
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

10-09-2007, 06:15 PM
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.