date function problem?

Hello,
I have a form and insert a record in another table when some fields are updated. One of the fields inserted is a datetime in Mysql which have to be saved with the current datetime. The problem I have is that sometimes, this datetime field adds one day to the current day (now). Say, for today’s date, 2013-08-08, the records are inserted in the table with the value 2013-08-09… I checked the date and time of the server and it is good, 2013-08-08, so I do not know what can be the problem. If I run the application from the IDE it saves the records with the correct date… Weird, huh? Any help is welcomed.

If it helps, this is the code I use in the onBeforeUpdate event of the form (took the template from the examples in SC)

/**

  • Insert a record on another table
    */

// SQL statement parameters

if ([v_change_flag]==1)
{
$insert_table = ‘table’; // Table name
$insert_fields = array( // Field list, add as many as needed
‘ProspectID’ => “’{ProspectID}’”,
‘PhaseChangeDate’ => “’[v_nw]’”,
‘CreationDate’ => “’[v_old_CreationDate]’”,
‘SalesStage’ => “’[v_old_SalesStage]’”,
‘NextSteps’ => “’[v_old_NextSteps]’”,
‘Comments’ => “’[v_old_Comments]’”,
);

// Insert record
$insert_sql = 'INSERT INTO ' . $insert_table
	. ' ('   . implode(', ', array_keys($insert_fields))   . ')'
	. ' VALUES ('    . implode(', ', array_values($insert_fields)) . ')';

sc_exec_sql($insert_sql);

};

Thank you.

[solved]

FYI
You have to change the timezone in the php.ini file… that took care of it.