Why is subtracting these two times (in 1927) giving a strange result? If I run the following program, which parses two date strings referencing times one second apart and compares them: public static void main(String[] args) throws ParseException { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str3 = "1927-12-31 23:54:07"; String str4 = "1927-12-31 23:54:08"; Date sDt3 = sf.parse(str3); Date sDt4 = sf.parse(str4); long ld3 = sDt3.getTime() /1000; long ld4 = sDt4.getTime() /1000; System.out.println(ld4-ld3); } The output is: 353 Why is ld4-ld3 not 1 (as I would
How do you create a JavaScript Date object with a set timezone without using a string representation
undefined
How do you create a JavaScript Date object with a set timezone without using a string representation I have a web page with three dropdowns for day, month and year. If I use the JavaScript Date constructor that takes numbers then I get a Date object for my current timezone: new Date(xiYear, xiMonth, xiDate) Give the correct date but it thinks that date is GMT+01:00 due to daylight savings time. The problem here is that I then give this Date to an Ajax
undefined
Determine a User's Timezone Is there any standard way for a Web Server to be able to determine a user's timezone within a web page? Perhaps from a HTTP header or part of the user-agent string? Answer: timezone.js: function ajaxpage() { var url = "timezone.php"; var visitortime = new Date(); var time = visitortime.getTimezoneOffset()/60; var page_request = false; if (window.XMLHttpRequest) { page_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { page_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ page_request = new ActiveXObject("Microsoft.XMLHTTP");