Tuesday, February 01, 2005

Javascript Date and Time

Javascript Date and Time 0 : The Date Object - J R Stockton: "Note that
  X = new Date() ; X.setYear(Y) ; X.setMonth(M-1) ; X.setDate(D)

will go wrong if the present date does not fit in the intended month; use
  X = new Date(Y, M-1, D)

instead. To set a date in the present but unknown year
  X = new Date() ; X.setDate(1) ; X.setMonth(M-1) ; X.setDate(D)

or the generally-forgotten
  X = new Date() ; X.setMonth(M-1, D)


If the Year may be small, use
X = new Date(0) ; X.setHours(0,0,0,0) ; X.setFullYear(Y, M-1, D)
."

No comments: