AnsweredAssumed Answered

Get JavaScript Date object from Date picker field

Question asked by community-support on Jan 13, 2014
Latest reply on Jan 13, 2014 by community-support
Hi all,

I need to get the value of a sugar Date field from JavaScript; document.getElementById('my_date_field').value returns the text from the field, but I want a Date object.

It doesn't appear that the value is stored as a Date object anywhere, only as text in the text field - so I'm guessing I'll need to parse the text using the current date format and turn it into a Date object.

However, I can't see a way of referencing the Calendar object after its been created, to get the date format, or indeed a good parse function to assist (the standard parseDate function actually just parses an input and then sets a formatted date string back onto the field which isn't very useful).

Anyone got any ideas?


(from SimonOBeirne)