0

Hi,
How to change date format in my sql.By default it is taken as 2011-03-05 but I want to change as 05-march-2010.
need your help

Thanks

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by mgranger96
0

I an inserting current date in a table using a curdate() function.& fetching date from a database.
2011-03-05 it takes this format by default.
I want to change this in to 05-march-2011

0

You can manipulate the date to display however you want on a php page. I'm not sure if you can change the format inside the database itself.

To change it on the php page you can use convert it to the hex number using strtotime() function then display it using the date function.

Example code:

$time = strtotime(DATEBASE VARIABLE CONTAINING DATE);
$myDate = date('d-M-Y, $time);

The date() function lets you manipulate how the date appears on the page. d is for day of the month, M displays the 3 letter month, use F for the full month name and Y is for the year. The '-' display and will show 05-Mar-2011. You can also use something like this (M d, Y) and this will show Mar 05, 2011.

Is this what you are trying to do?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.