How can I convert the time from the format “Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)” to YYYY-MM-DD.
When I try to alert() the date then this will show the date like the following
– Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)
But I need the time in YYYY-MM-DD format.
Are there any built function to convert?
You can parse the date using the
Dateconstructor, then spit out the individual time components:As you can see from the result though, this will parse the date into the local time zone. If you want to keep the date based on the original time zone, the easiest approach is to split the string and extract the parts you need: