Mostafa Fallah
Mostafa Fallah

Reputation: 398

Convert Date in PHP?

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

Upvotes: 2

Views: 76

Answers (2)

Hardik
Hardik

Reputation: 439

Try this one..

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

echo date('Y/m/d H:i', strtotime($str));

Upvotes: 1

Omkar Frozen
Omkar Frozen

Reputation: 155

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

Upvotes: 1

Related Questions