Victor Kimura
asked on
return Javascript Date object rather than string
Hi,
I have this object returned as:
events : [
{
"id":1,
"start": Thu May 28 2012 14:00:00 GMT-0700 (Pacific Daylight Time),
"end": Thu May 28 2012 15:00:00 GMT-0700 (Pacific Daylight Time),
"title":"Lunch with Mike"
},
{
"id":2,
"start": Thu May 30 2012 16:00:00 GMT-0700 (Pacific Daylight Time),
"end": Thu May 30 2012 18:30:00 GMT-0700 (Pacific Daylight Time),
"title":"Dev Meeting"
}]
But I need to return the "start" and "end" dates as:
events : [
{
"id":1,
"start": new Date(year, month, day, 12),
"end": new Date(year, month, day, 13, 30),
"title":"Lunch with Mike"
},
{
"id":2,
"start": new Date(year, month, day, 14),
"end": new Date(year, month, day, 14, 45),
"title":"Dev Meeting"
}]
How do I convert the string to the Date object? Is there an easy way? I'm drawing the "start" and "end" dates in the string format from the database.
Thanks,
Victor
I have this object returned as:
events : [
{
"id":1,
"start": Thu May 28 2012 14:00:00 GMT-0700 (Pacific Daylight Time),
"end": Thu May 28 2012 15:00:00 GMT-0700 (Pacific Daylight Time),
"title":"Lunch with Mike"
},
{
"id":2,
"start": Thu May 30 2012 16:00:00 GMT-0700 (Pacific Daylight Time),
"end": Thu May 30 2012 18:30:00 GMT-0700 (Pacific Daylight Time),
"title":"Dev Meeting"
}]
But I need to return the "start" and "end" dates as:
events : [
{
"id":1,
"start": new Date(year, month, day, 12),
"end": new Date(year, month, day, 13, 30),
"title":"Lunch with Mike"
},
{
"id":2,
"start": new Date(year, month, day, 14),
"end": new Date(year, month, day, 14, 45),
"title":"Dev Meeting"
}]
How do I convert the string to the Date object? Is there an easy way? I'm drawing the "start" and "end" dates in the string format from the database.
Thanks,
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome. Thanks for the grade & points.
Good luck & have a great day.
Good luck & have a great day.
ASKER