Skip to content

Instantly share code, notes, and snippets.

@shingorow
Created February 27, 2017 12:07
Show Gist options
  • Select an option

  • Save shingorow/e2e5f92a5916f1ec998ce4a199e7d256 to your computer and use it in GitHub Desktop.

Select an option

Save shingorow/e2e5f92a5916f1ec998ce4a199e7d256 to your computer and use it in GitHub Desktop.

Revisions

  1. shingorow created this gist Feb 27, 2017.
    21 changes: 21 additions & 0 deletions set-value-to-today.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    (function(global) {
    function SetValueToToday(className) {
    var date = new Date(),
    year,
    month,
    day,
    today;

    this.className = className || 'set-value-to-today';
    this.className = this.className.replace(/^\./, '');

    year = date.getFullYear();
    month = date.getMonth() + 1;
    day = date.getDate();
    today = year + '/' + month + '/' + day;

    $('.' + this.className).val(today);
    }

    global.SetValueToToday = SetValueToToday;
    }(this));