0

CODE 1

<?php
ini_set('date.timezone', 'Asia/Kuala_Lumpur');
$today = Date('y.m.d H:i:s');                // current time
echo $today;
?>

CODE 2

<?php
ini_set('date.timezone', 'Asia/Kuala_Lumpur');
$today = Date('y.m.d H:i:s');                // current time
$query= "UPDATE items SET post_date = '{$today}' WHERE item_name='$item_name'";
mysql_query($query);
?>

hi all, as you all can see, i have two similar code above,for the first one, it run well and i get what i want. But for the second code, when i trying to save the time into my database, it show the wrong time

let say if i run it now, the correct output is 11.04.09 16:35:13
however after i update it into database ,it show 11.04.09 01:35:13
so may i know how should i set the database type?
im using timestamp now.
thank you

Edited by Nick Evan: Fixed formatting

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by diafol
0

Timestamp??
For datetime: use format (Y-m-d H:i:s)

Personally I'd use integer field and use unix timestamp (seconds since unix epoch) after the setting of the tz.

I used to use this:

date_default_timezone_set($tz);

I don't know how that compares to your method.

My online datecalc: http://diafol.org/datetime.php (Bahasa Melayu friendly)

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.