Search code examples
javascriptjqueryinline-code

inline javascript to render text year


I currently have a datestamp after a copyright statment I would like to have the year after the - to be dynamic is there a way to sub in some javascript to write the year in as it changes see below for what i am hoping for

1994-2015 1994-

Solution

  • use js date object:

    var year = new Date().getYear();
    

    As per the comment about this method being deprecated, you can also use:

    var year = Date().getFullYear();