MySQL Forums
Forum List  »  Newbie

Re: how to convert timestamp value to string in MySql
Posted by: Matt Pellegrino
Date: April 26, 2009 01:15AM


Depending on your setup, you can do this different ways. If you have saved a MySQL style timestamp in your database, you can actually select it directly and save it to a string. This assumes your timestamp column name is "timestamp". Depending on what you want out of the timestamp different select statements can be used.

$sql = "SELECT date(timestamp) from test_db;

$sql = "SELECT time(timestamp) from test_db;

//2009-04-26 03:13:13
$sql = "SELECT timestamp(timestamp) from test_db;

You can take this date string or you can convert it further to a Unix timestamp using PHP's function strtotime():

Matt Pellegrino
Support Engineer
mpellegrino @

Options: ReplyQuote

Written By
Re: how to convert timestamp value to string in MySql
April 26, 2009 01:15AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.