The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.
var currentdate = new Date();
currentdate.getMonth();
For example, this return 5 instead of 6.
Hi Asekar,
getMonth() method returns the month (from 0 to 11) for the specified date, according to local time.
The month number would be : currentdate.getMonth()+1
Are you looking for the month Name (January, ...) ? Do you want it localized ?
Is there a need to extract the month from the date? Or is it just a problem where the month value is being read wrong when you use parsedate function?
If it is the second one, then you could try changing the format string in the parsedate function. I believe Thingworx uses joda-time for the date functions internally. So you can try a format like this:
var result = parseDate(date, "dd/MM/yyyy");
This would make the parse date function search for days of the month (01-31), Month of the year (01-12), Year. Confusion between using mm and MM is very common.
If this doesn't work you could maybe share a snippet of your code, so everyone can understand better what is it your trying to do here.