Javascript Date is One Day Off

ben himself's picture

In JavaScript, dates are based on the UTC time, the starting timezone which all others are based on. You may have a date in JavaScript that should be one particular date but for some reason changes itself to the previous day. The way to fix it is to add the timezone offset to the date. Here's an example:

jsfiddle example: https://jsfiddle.net/xhzce36p/1/

jQuery Toggle Firing Twice

ben himself's picture

When trying to toggle an element on a page using jQuery, you might have the toggle happen multiple times. In other words, you click the event listening element (such as a link) and the element you want to toggle expands and collapses, then once more expands and collapses. Obviously, this is not the effect we are going for.

The reason seems to be that the element was bound more than once so it fires once for each binding. The solution is to unbind the element before calling the toggle.

Tags: 

Post date
Script Storage Wednesday, May 2, 2018 - 20:29
sp_who2 Alternative (T-SQL, SQL Server) Tuesday, May 1, 2018 - 06:04
Discover How User Is Accessing SQL Instance (PowerShell and T-SQL) Monday, April 30, 2018 - 21:17
MySQL - Move Data Files To New Location (Windows) Thursday, February 15, 2018 - 20:38
PowerShell With Uptime - Getting Days Only Saturday, December 16, 2017 - 16:10
Removing SSMS Boost Friday, June 30, 2017 - 16:04
Flickr Searching Sunday, June 18, 2017 - 18:44
PowerShell - Arrays Friday, May 12, 2017 - 20:19
One Off Thought - Back to Top Monday, February 20, 2017 - 16:31
TempDB Reporting Incorrect File Size Friday, January 20, 2017 - 23:24