Skip to content

Instantly share code, notes, and snippets.

@zehfernandes
Last active January 12, 2016 18:59
Show Gist options
  • Save zehfernandes/ef23ee6239623f231935 to your computer and use it in GitHub Desktop.
Save zehfernandes/ef23ee6239623f231935 to your computer and use it in GitHub Desktop.
Check daylight savetime

Install

npm install moment
npm install time

Code

var nt        = require('time'),
    moment    = require('moment');

function dateDaylightUnix(datestring) {
    var date      = moment(datestring, 'DD/MM/YYYY hh:mm'),
        localtime = nt.localtime( date.toDate().getTime() / 1000);

    if ( localtime['isDaylightSavings'] == true) {
      date.subtract({ hours: 1 });
    }

    return date.unix();
}

var timestamp = dateDaylightUnix("30/03/1965 03:00");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment