PDA

View Full Version : Get year in two digits?


Nasimov
Thu 13th Nov '03, 11:04am
How to get year in two digits ? Example for 2003 to get 03 ?
I use:

var year=mydate.getYear()

but this returns four digits year ?

doron
Thu 15th Jan '04, 9:00pm
First of all, use getFullYear(), it is truly y2k safe.

2nd, just do:

new Date().getFullYear().toString().substring(2,4)

to get the last 2 numbers.