Hi all,
I have a database running on GMT Timezone and it is accessed via website by people in USA on EST timezone.
I want the current date and time inserted into database. When I use it the datetime is correctly entered.
However, when those on EST time use it the datetime 01/01/1900 is entered.
Why is this?
Here's my code for date formatting...
/*********** Format Date for EST *************/
// a) Get todays date and time
$todays_date = date('Y-m-d H:i:s');
// b) Split $todays_date value
list($year, $month, $day, $time) = split('[/. -]', $todays_date);
$file_date = $year.'-'.$month.'-'.$day;
// c) Format Time
list($hr, $min, $sec) = split('[:]', $time);
$hr = $hr - 05;
$time = $hr.':'.$min.':'.$sec;
// d) Combine Date & Time
$datetime = $file_date.' '.$time;
// e) Complete Datetime Formatting
$file_date = date("Y-m-d H:i:s" ,strtotime($datetime));
// insert data into database
$query = "INSERT INTO excel(name, file_date) ".
"VALUES('$fileName', '$file_date')";
echo $query;
$result = mssql_query($query) or die('Insert Error');
Thanks.