In a script I use the Date() constructor to get the current date and time.
As it turns out, this results in the GMT date/time (universal time).
As I'm living in the Netherlands, this is 2 hours earlier than the local time (1 hour plus 1 hour for daylight saving). To compensate this I use the getTimezoneOffset() method. This method, however, returns 0. What do I do wrong here?
function checkTime()
{
var now = new Date();
alert('now.getHours() is ' + now.getHours()
+ '; now.getUTCHours() is ' + now.getUTCHours()
+ '; now.getTimezoneOffset() is '+ now.getTimezoneOffset()
+ '; now.toString() is ' + now.toString()
);
}
Results at 22:13 pm local time:
now.getHours() is 20; now.getUTCHours() is 20; now.getTimezoneOffset() is 0; nowtoString() is Sun, 13 apr, 2013:33
Help!
Unable to get the local time in a script
- bertkessels
- Posts: 15
- Joined: 6. Nov 05, 14:05 [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
- bertkessels
- Posts: 15
- Joined: 6. Nov 05, 14:05 [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script
The problem seems to be related to the windows option for automatic adaption to daylight saving time.
(In the dutch Windows version this is the option: "Klok automatisch aanpassen aan zomertijd en wintertijd", its on the timezone tab of the date/time settings)
I switched the option off and getHours() now returns the local time correctly, getTimeZoneOffset() returns now -60 (minutes) which is correct. Is this a bug in Windows or in Silverjuke?
(In the dutch Windows version this is the option: "Klok automatisch aanpassen aan zomertijd en wintertijd", its on the timezone tab of the date/time settings)
I switched the option off and getHours() now returns the local time correctly, getTimeZoneOffset() returns now -60 (minutes) which is correct. Is this a bug in Windows or in Silverjuke?
- Service-Team
- Posts: 2448
- Joined: 7. Dec 04, 04:48
- Location: Germany [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script
Hello bertkessels,
thank you for your report, we will check this when we update the underlying JavaScript-engine in one of the next Silverjuke updates.
Best regards,
Your Silverjuke-Team
thank you for your report, we will check this when we update the underlying JavaScript-engine in one of the next Silverjuke updates.
Best regards,
Your Silverjuke-Team
- bertkessels
- Posts: 15
- Joined: 6. Nov 05, 14:05 [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script
OK. Thanx.
I have a work-around for now, so no hurry.
regards,
Bert
I have a work-around for now, so no hurry.
regards,
Bert
-
- Posts: 713
- Joined: 30. Sep 08, 14:00
- Location: Netherlands [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script
Hi Team,
One year later, 16:01 on the wallclock and in Windows (XP). But Silverjuke still thinks both new Date().getHours() and new Date().getUTCHours() are 14...
How do I get a correct local time with 16 hours? (And no, deactivating automatic summertime in XP is not an option
)
SilverEagle
One year later, 16:01 on the wallclock and in Windows (XP). But Silverjuke still thinks both new Date().getHours() and new Date().getUTCHours() are 14...
How do I get a correct local time with 16 hours? (And no, deactivating automatic summertime in XP is not an option

SilverEagle
Last edited by SilverEagle on 16. Apr 09, 22:19, edited 1 time in total.
- Frenchi
- Posts: 352
- Joined: 6. Apr 08, 17:26
- Location: Grenoble / France [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script


-
- Posts: 713
- Joined: 30. Sep 08, 14:00
- Location: Netherlands [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
-
- Posts: 713
- Joined: 30. Sep 08, 14:00
- Location: Netherlands [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script
Hi Team,
SilverEagle wrote:
> How do I get a correct local time
> ...
Any input on this issue?
Regards,
SilverEagle
SilverEagle wrote:
> How do I get a correct local time
> ...
Any input on this issue?
Regards,
SilverEagle
- Service-Team
- Posts: 2448
- Joined: 7. Dec 04, 04:48
- Location: Germany [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Unable to get the local time in a script
Sorry for some delays, however, we have this point on our todo-list.
Best regards,
Your Silverjuke-Team
Best regards,
Your Silverjuke-Team