I have a date in YDDD format such as 3212
I want to convert this date to a default date string, i.e. 2013-08-01 in PHP
Since the first Y value is the only character for Year, so I decided to take the first three characters from the current year i.e. 201 from 2013
Below is the code I wrote during the year
<?php $date = "3212" $y = substr($date,0,1); // will take out 3 out of year 3212 $ddd = substr($date,1,3); // will take out 212 out of year 3212 $year = substr(date("Y"),0,3) . $y; //well create year "2013" ?>
Now How to use $year and 212 to convert it to 2013-08-01 using PHP
EDIT
FYI: My PHP Version 5.3.6
date php
zzlalani
source share