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

Recommended Answers

All 3 Replies

Where do you want to change the date? When you display the results on a page?

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

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.