0

I have a code that splits the date and assigns each value in a var:

// Jun 22 2015  - 08:00:00 AM MYT
var parts = record.emsDateTime.split("-");
var date = parts[0];
var dt = date.split(" ");
var tm = parts[1];

var yr = Number(dt[2].replace(/\s/g,''));
var mon = Number(months[dt[0]]);
var dy = Number(dt[1]);

var apmRgx = /(AM|PM)/gi;
var apm = tm.toString().match(apmRgx);
var hr = Number(tm.split(":")[0]);
var mint = Number(tm.split(":")[1]);
var scnd = 0;

PV.Logger.logInfo("LOGGED >>>", "onReadRecordTimestampCheck", yr + " " + mon + " " + dy + " " + hr + " " + mint + " " + apm);

Based from the sample date (commented code) the month is June but when i print out the values:

onReadRecordTimestampCheckI 2015 5 22 8 0 AM    

It shows "5" which means its May. Does the Month also starts with zero? or is any issue on my code?

Arnold Cristobal
  • 843
  • 2
  • 16
  • 36

1 Answers1

0

I believe this is because the months are displayed 0-11, and not from 1-12 like you're thinking.

getMonth()

WWZee
  • 494
  • 2
  • 8
  • 23