This question already has an answer here:
I call php from javascript. Url address is http://xxx.xx.x.xx/wdcalendar/novaoperacia.php?start=Tue Jun 18 18:00:00 UTC+0200 2013. It is not suitable for me. I want to convert do format YYYY-MM-DD. But in js. How can I make it ? Or how can I make it in php ?
</div>
In javascript:
Your input:
var s = "Tue Jun 18 18:00:00 UTC+0200 2013";
Instantiate the Date object:
var d = new Date(s);
Use standard Date methods: (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) using the slice on the last two methods to get 2 digits for each
var yyyy = d.getFullYear();
var mm = ("0" + (d.getMonth() + 1)).slice(-2);
var dd = ("0" + d.getDate()).slice(-2);
The final output declaration:
var out = yyyy + '-' + mm + '-' + dd;
console.log(out);
Outputs "2013-06-18"