I have the following date format in a xml sh开发者_运维知识库eet: Jan 30 and I want to display as: 2011-01-30
2011 being the current year
Can someone help me with that?
strtotime will use the current year if none is specified, so this would work
$t=strtotime("Jan 30");
echo strftime("%Y-%m-%d", $t);
strtotime + date gives you:
echo date("Y-m-d", strtotime('30 Jan')); //echoes '2011-01-30'
care to post the xml?
in anycase, take the string
$x = "Jan 30"
add 2011
$x = $x . ' ' . date('Y');
convert it to date time and format it
$y = date_format('Y-m-d', strtotime($x));
echo $y;`
strtotime is your key here, it converts most any date format into seconds since the epoch, then all you need do is use the date_format function
ps... if you like my answer, accept it as the answer to bring your accepted question ratio, otherwise people will be less likely to answer your questions
加载中,请稍侯......
精彩评论