Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Detect Daylight Saving Time on a MySQL server in the America/New_York timezone.

   1  
   2  SELECT -5 - CAST(REPLACE(TIMEDIFF(NOW(), UTC_TIMESTAMP()), ':00:00', '') AS SIGNED) AS isDst

To test in other timezones, replace -5 with your local standard time GMT offset.

Place Timezone information into a cookie

Set a cookie with the users timezone

   1  
   2  //By default, getTimezoneOffset returns the time zone offset in minutes
   3  setCookie("timezone", new Date().getTimezoneOffset()/60);
   4  
   5  function setCookie(name, value, expires, path, domain, secure) 
   6  {
   7      document.cookie= name + "=" + escape(value) +
   8          ((expires) ? "; expires=" + expires.toGMTString() : "") +
   9          ((path) ? "; path=" + path : "") +
  10          ((domain) ? "; domain=" + domain : "") +
  11          ((secure) ? "; secure" : "");
  12  }
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS