-1

I need convert month Name to month number and datetime to date date come from sql 1/oct/2013 0:00 need to convert 1/10/2013 how? Very Thanks

3
  • 1
    It's kinda insane to store dates in a database like that, use date/time datatypes for those columns Commented Mar 23, 2015 at 10:03
  • datatype in db datetime and value 1/10/2013 12:00:00 AM Commented Mar 23, 2015 at 10:05
  • If the database holds a datetime, then why do you have this obscure format with a month name that you need to convert? Commented Mar 23, 2015 at 10:07

1 Answer 1

0

Showing how to convert dates from one format to another is duplicated many times here on SO

$date = DateTime::CreateFromFormat('j/M/Y', '1/oct/2013');
echo $date->format('d/m/Y');

EDIT

If you absolutely can't update from a version of PHP that has been end of life since 6th January 2011, then you can convert your format to a slightly more regular format that will be recognised by strtotime()

$date = strtotime(str_replace('/','-','1/oct/2013'));
echo date('Y-m-d', $date), PHP_EOL;

But I'd strongly recommend updating your version of PHP.... or at least telling people what version you're running when you ask questions (because it makes a lot of difference to the answers you'll get)

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

4 Comments

not work this eror Fatal error: Call to undefined method DateTime::createfromformat()
Then you're using a pretty old version of PHP: ConvertFromFormat() was introduced in version 5.3.0..... what version of PHP are you using? And you do realise that it's not a version that's supported any more.
I am used php5.2.9-2
Very Thanks Mark Baker it work prefect

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.