php - Change data format from mm/dd/yyyy to yyyy-mm-dd -


i have data string data in format -> 03/15/2014 (mm/dd/yyyy) , need replace date in format 2014-03-15 (yyyy-mm-dd).

i know how change '/' '-', don't know how turn 2014 end start.

try this

$dates = explode("/","03/15/2014"); $newdate = $dates[2]."-".$dates[0]."-".$dates[1]; 

this works in version of php

note: input date should of format mm/dd/yyyy

if php less 5 can use this. if php > 5 advised use datetime class advised gordonm in order find date valid or not .

demo


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -