1

All,

I have a MYSQL table that has a column "DT_Created" defined with timestamp datatype. I would like to write a select query to retrieve the timestamp in the following fashion:

Sat, MM/DD/YYYY HH:MM:SS AM CST Lengthy Explanation: Day, Month/Date/4 Digit Year Hours:Minutes:Seconds AM or PM TimeZone 

2 Answers 2

3

Use the DATE_FORMAT command (see the Reference Manual).

SELECT DATE_FORMAT(DT_Created, '%a, %c/%d/%Y %T %p') AS formatted FROM ... 

The time zone is a bit more difficult... I'm not even sure in which timezone it will format the time.

Sign up to request clarification or add additional context in comments.

Comments

1

retrieve it by using a query as such:

$sql = "SELECT UNIX_TIMESTAMP(DT_Created) as timeToFormat FROM table"; $result = mysql_query($sql); $row = mysql_fetch_array($result); 

then you can format it with

$date = date("M/D/Y H:i:s",$row['timeToFormat']); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.