Link to home
Start Free TrialLog in
Avatar of Victor Kimura
Victor KimuraFlag for Canada

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
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Victor Kimura

ASKER

Thank you. That works. =)
You are welcome.  Thanks for the grade & points.

Good luck & have a great day.