Page 1 of 1

Timestamps

Posted: Sun Oct 12, 2003 3:04 pm
by Splui
In the following example the field name is a string and date is of type datetime.

A query, SELECT name, date FROM sometable returns a result set. This is placed in $result and accessed via $info=mysql_fetch_array($result).

A while loop takes each field in turn and places them in local variables $name and $date respectively.

The $date seems to be giving me a timestamp of just the year (ie e.g. 2002-01-11 00:00:00 gives the timestamp 2002) which, when used via the date() function, always gives Jan 1, 1970 1.33am.

A straight output of $date shows the correct full date and time but I want to format the output.

Any ideas how to get the full timestamp?

Much obliged

splui

Posted: Sun Oct 12, 2003 3:22 pm
by devork
select unix_timestamp(date_col) from your table..
will give you the time stamp of date and then you can convert it into you own format ...
for more information refer to mysql date time functinon ..

Posted: Sun Oct 12, 2003 5:50 pm
by Splui
Worked a treat, thanks a lot!!

splui