Js gets the time code for the current time zone when daylight saving time occurs and terminates
<!DOCTYPE html><html><head><title>DST Calculator</title><script type="text/javascript">function DisplayDstSwitchDates(){var year = new Date().getYear();if (year < 1000)year += 1900;var firstSwitch = 0;var secondSwitch = 0;var lastOffset = 99;// Loop through every month of the current yearfor (i = 0; i < 12; i++){// Fetch the timezone value for the monthvar newDate = new Date(Date.UTC(year, i, 0, 0, 0, 0, 0));var tz = -1 * newDate.getTimezoneOffset() / 60;// Capture when a timzezone change occursif (tz > lastOffset)firstSwitch = i-1;else if (tz < lastOffset)secondSwitch = i-1;lastOffset = tz;}// Go figure out date/time occurences a minute before// a DST adjustment occursvar secondDstDate = FindDstSwitchDate(year, secondSwitch);var firstDstDate = FindDstSwitchDate(year, firstSwitch);if (firstDstDate == null && secondDstDate == null)return 'Daylight Savings is not observed in your timezone.';elsereturn 'Last minute before DST change occurs in ' +year + ': ' + firstDstDate + ' and ' + secondDstDate;}function FindDstSwitchDate(year, month){// Set the starting datevar baseDate = new Date(Date.UTC(year, month, 0, 0, 0, 0, 0));var changeDay = 0;var changeMinute = -1;var baseOffset = -1 * baseDate.getTimezoneOffset() / 60;var dstDate;// Loop to find the exact day a timezone adjust occursfor (day = 0; day < 50; day++){var tmpDate = new Date(Date.UTC(year, month, day, 0, 0, 0, 0));var tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;// Check if the timezone changed from one day to the nextif (tmpOffset != baseOffset){var minutes = 0;changeDay = day;// Back-up one day and grap the offsettmpDate = new Date(Date.UTC(year, month, day-1, 0, 0, 0, 0));tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;// Count the minutes until a timezone chnage occurswhile (changeMinute == -1){tmpDate = new Date(Date.UTC(year, month, day-1, 0, minutes, 0, 0));tmpOffset = -1 * tmpDate.getTimezoneOffset() / 60;// Determine the exact minute a timezone change// occursif (tmpOffset != baseOffset){// Back-up a minute to get the date/time just// before a timezone change occurstmpOffset = new Date(Date.UTC(year, month,day-1, 0, minutes-1, 0, 0));changeMinute = minutes;break;}elseminutes++;}// Add a month (for display) since JavaScript counts// months from 0 to 11dstDate = tmpOffset.getMonth() + 1;// Pad the month as neededif (dstDate < 10) dstDate = "0" + dstDate;// Add the day and yeardstDate += '/' + tmpOffset.getDate() + '/' + year + ' ';// Capture the time stamptmpDate = new Date(Date.UTC(year, month,day-1, 0, minutes-1, 0, 0));dstDate += tmpDate.toTimeString().split(' ')[0];return dstDate;}}}</script></head><body><script type="text/javascript">document.write("Current date/time: " + new Date() + "<br />");document.write(DisplayDstSwitchDates());</script></body></html>