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

Member Avatar for diafol

Use [ CODE ] tags

Member Avatar for diafol

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)

thanks all..i think solved...

Member Avatar for diafol

Ok, mark it solved if so.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.