Jump to content

Archived

This topic is now archived and is closed to further replies.

tribal

date format question

Recommended Posts

hi, i got a DB field that is a DATETIME format and is automatically entered when a user registers. how do i change format from 2003-10-22 10:05:06

 

to something like 10/22/2003 10:05 ??

 

can i modify the existing mysql format?

Share this post


Link to post
Share on other sites

From MySQL manual:

 

MySQL retrieves and displays DATETIME values in \'YYYY-MM-DD HH:MM:SS\' format.

 

I had the same issue and wanted to store the date in mysql in a custom format. I defined the column to be a TEXT instead of DATETIME and populated it with PHP

[php:1:44d99b4a40]<?php

$datetime = date(\"d/m/Y h:i\");

?>[/php:1:44d99b4a40]

 

Hope it helps.

Share this post


Link to post
Share on other sites

... and in doing so. lost the ability to sort it into sequence, use comparison operators or use any of the dozens of date/time functions provided.

 

Leave it as it is in the database and format it on output.

Share this post


Link to post
Share on other sites

I was searching the same problem. I would like to change it on output but i can't find any functions that will do that. They only format the time as it is now. I want to take any date from the DATE on mysql and change it to eg. Jan. 11, 2005 .. can anyone help me find a function that will do this, thanks!

Share this post


Link to post
Share on other sites

Use the mysql DATE_FORMAT() function in your query, you can find it in the date and time function section of the mysql manual.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.