V8JS Timezone Test Fails - javascript

I'm trying to install V8JS but a timezone test is failing. This test:
https://github.com/phpv8/v8js/blob/php7/tests/timezones.phpt
I followed these instructions https://github.com/phpv8/v8js/blob/php7/README.Linux.md
The issue the test has is that the Date printed is wrong:
================================================================================
001+ string(15) "Europe/Helsinki"
002+ Thu Mar 20 2014 11:03:24 GMT+0200 (Eastern European Standard Time)
003+ string(16) "America/New_York"
004+ Thu Mar 20 2014 11:03:24 GMT+0200 (Eastern European Standard Time)
005+ string(15) "Europe/Helsinki"
006+ Thu Mar 20 2014 11:03:24 GMT+0200 (Eastern European Standard Time)
001- Thu Mar 20 2014 11:03:24 GMT+0200 (EET)
002- Thu Mar 20 2014 05:03:24 GMT-0400 (EDT)
003- Thu Mar 20 2014 11:03:24 GMT+0200 (EET)
================================================================================
The upper 6 Lines are the ACTUAL output. I added a var_dump(getenv('TZ')); to make sure that the timezone is getting changed. The last 3 lines are the expected output. As you can see everything is GMT+0200 which is wrong, only 2 should be +0200
I've checked my php.ini and remove any timezone settings, this did not help at all sadly. Same issue.
Has anyone ever run into something similar? Or Does anyone have an Idea?
I've tried just using V8JS as is, but it crashes sadly.

I compiled a third version of V8 (6.5.143) and this fixed the problem. Not sure why, but atleast the test works now.

Related

MomentJs and dayjs both have wrong date for timezone

I'm running this code at 9:21am in London UK on Wednesday 10 August.
console.log(moment.tz(date, "America/New_York").startOf("day"), "start!")
console.log(moment.tz(date, timezone).startOf("day"), "timezone current!")
(also ran with dayjs replacing moment, results the same)
the first log returned: Tue Aug 02 2022 01:00:00 GMT+0100 (British Summer Time) {}
the second returned: Wed Aug 03 2022 01:00:00 GMT+0100
The second is correct (mostly), I'd expect 00:00:00but at least the date is right
The time currently in NY is 04:21 so why does it think the current startOf('day') date is yesterday when clearly it's still today?

Datepicker, same code, different localization chrome/IE

I am using datepicker with localization.
It all works great but i have a problem.
var selected_date = jQuery('.datepicker').datepicker('getDate');
selected_date = new Date(selected_date);
Output on Chrome :
Wed Oct 24 2018 00:00:00 GMT+0300 (Eastern European Summer Time)
Output on IE 11 :
Wed Oct 24 2018 00:00:00 GMT+0300 (GTB Summer Time)
How is that possible happening in same server, same time and same conditions.

Javascript huge date bug in windows... Solutions?

My dev environment is in mac.
I use bootstrap datepicker to choose dates in an application.
When a day like 27/11/2013 is selected in mac when I debug, the screen shows...
day: 1385510400
and the translation to an date object in the same debug tool is,
Wed Nov 27 2013 00:00:00 GMT+0000 (GMT)
which is correct.
All is OK, since here.
I upload the code to a windows environment and open the same page with IE8.
Start the nightmare... :)
In windows, the same day variable is shown like that...
day: 1385506800
and the translation to an date object in the same debug tool is,
Wed Nov 27 2013 00:00:00 GMT+0000 (GMT)
which, is not correct?
If we go to a external tool, the day that gave IE8 is day before, and the translation should be,
Tue, 26 Nov 2013 23:00:00 GMT.
How I can understand this?
There is no relation with the timestamp and the translation to date object, and obviously I can't find a way to make this works in both systems.
Could you wake me up from this nightmare?
Sorry for my english!
Fiddle
In JS in Chrome:
new Date(1385510400000) : Wed Nov 27 2013 01:00:00 GMT+0100
new Date(1385506800000) : Wed Nov 27 2013 00:00:00 GMT+0100
new Date("11/27/2013") : Wed Nov 27 2013 00:00:00 GMT+0100
Please note the order of the date string, it is in US order
Also note the 000 at the end; JS timestamps are in milliseconds
The same in IE8
Wed Nov 27 01:00:00 UTC+0100 2013
Wed Nov 27 00:00:00 UTC+0100 2013
Wed Nov 27 00:00:00 UTC+0100 2013
So exactly the same dates, on hour difference on the first
If you subtract the 1 hour from all dates, you get midnight on the first and 11pm on the 26th on the rest
To normalise you can do
var d = new Date(1385510400000);
d.setHours(0,0,0);
or change to UTC

I want Date format in IST extension(November 12th 2013 - 11:58 AM IST)

I am using
"Tue Nov 12 2013 11:58:53 GMT+0530 (India Standard Time)"..match(/\(([^\)]+)\)$/)[1]).match(/\b(\w)/g).join("");.
But it is not working in IE10. Please help me to get exptected format.
thanks
This works for me:
"Tue Nov 12 2013 11:58:53 GMT+0530 (India Standard Time)".match(/\(([^)]+)\)$/)[1].match(/\b(\w)/g).join(""); // == "IST"
But please keep in mind to make proper verification should the base string be different from that static one.

Difference in converted dates windows and mac

I found out that on a mac my script is acting different than on a windows. On both systems i am using chrome as the browser, i don't know how to explain my problem properly so ill show you. Below the Javascript function it converts a json time to a javascript date.
function getDateFromJSON(value) {
var retvalue = new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
return retvalue
}
When i use this function with a json date string on a windows pc as shown bellow the output is: Sat Oct 22 1988 00:00:00 GMT+0200 (W. Europe Daylight Time)
When i use the same function with a mac the output is: Fri Oct 21 1988 23:00:00 GMT+0100 (CEST)
The code i used on both mac and windows is:
console.log(getDateFromJSON("/Date(593474400000)/"));
Can someone please help me explain how i can fix this?
Both dates are the same (after adjusting for timezones)
If you want to standardize, use toUTCString:
> new Date(" Sat Oct 22 1988 00:00:00 GMT+0200 (W. Europe Daylight Time)").toUTCString()
'Fri, 21 Oct 1988 22:00:00 GMT'
> new Date("Fri Oct 21 1988 23:00:00 GMT+0100 (CEST)").toUTCString()
'Fri, 21 Oct 1988 22:00:00 GMT'

Categories