Get year in two digits?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nasimov
    New Member
    • Nov 2003
    • 2

    Get year in two digits?

    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
    Senior Member
    • Apr 2000
    • 669

    #2
    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.

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...