2

I have a string with day and month name. How can I convert to standard date? I have this :

Tue 19Jul16 13:30

I want to show me this :

2016/07/19 13:30
Abdul Hameed
  • 263
  • 4
  • 19
Mostafa Fallah
  • 398
  • 3
  • 19
  • 1
    `echo date('Y/m/d H:i', strtotime('Tue 19Jul16 13:30')); // 2016/07/19 13:30` – splash58 Jun 08 '16 at 11:37
  • 2
    Possible duplicate of [Convert one date format into another in PHP](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Chetan Ameta Jun 08 '16 at 11:47

2 Answers2

1

Try this one..

$str = "Tue 19Jul16 13:30";

echo date('Y/m/d H:i', strtotime($str));
Hardik
  • 448
  • 2
  • 9
1

if you want to convert html date this is the code I prepared in javascript just pass $date to cnvrt() from php

function cnvrt(datee)
{
var d=datee;
  month = '' + (d.getMonth() + 1),
        day = d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;

   datee= [month, day, year].join('/');

}

So rather than echo you can use the date wherever you need

Omkar Frozen
  • 157
  • 9