Greetings and apologies for my limited English skills :-)
I am facing a challenge with my JSON data.
In my MySQL database, I have stored dates in the format YYYY.MM.DD. However, I require the format DD.MM.YYYY. So, I modified the query as follows:
$rs = mysql_query("SELECT event_name, DATE_FORMAT(beginn,'%d.%m.%Y'), DATE_FORMAT(ende,'%d.%m.%Y') FROM party WHERE ende >= CURDATE() ORDER BY beginn ASC");
Now, I receive the string with the correct date format
{"summer":[{"event_name":"testevent","DATE_FORMAT (beginn, '%d.%m.%Y')":"28.01.2015","DATE_FORMAT (ende, '%d.%m.%Y')":"30.01.2015"}]}
However, I am facing an issue with my JavaScript code. Previously, when using DATE_Format (beginn,'%d.%m.%Y'), I was able to retrieve the date (albeit not in the desired format). Now, I am receiving no output.
Below is my JavaScript code:
var url="party.php";
var activitydetail = sessionStorage.activitydetail;
$.getJSON(url,function(json){
$.each(json.summer,function(i,item){
$('<li><a href="#'+item.event_name+'"> '+item.DATE_FORMAT (beginn, '%d.%m.%Y')+' - '+item.event_name+'</a></li>').appendTo('#accor2');
});
});
The function is no longer working with '+item.beginn+'
and
'+item.DATE_FORMAT(beginn, '%d.%m.%Y')+'
Does anyone have a solution?
Thank you in advance :-)