gs.beginningOfThisMonth(), show a difference of 1 hour.

vikrantsharma
Kilo Guru

Hi All,

I have been coding a Script Include, in which I am using gs.beginningOfThisMonth(). However, I could see that the script was not executing correctly, on investigating it further, I found that there is a difference of 1 hour when I use gs.beginningOfThisMonth(). 

The instance in on Europe/London, and if I use gs.nowDateTime() in the script it works fine.

For testing purpose, I am using the below script and getting the result as shown, and we are on Kingston patch 7.

Has anyone else noticed the same behavior?

gs.log("Beginning of the month: "+gs.beginningOfThisMonth());
gs.log("Get the current time: "+gs.nowDateTime());

*** Script: Beginning of the month: 2018-06-30 23:00:00 // This should be 2018-07-01 00:00:00
*** Script: Get the current time: 23/07/2018 08:57:13 // This is the correct time.


Regards,

Vikrant Sharma

Please make it correct or helpful if this solves or help you with your issue for other to make use it.

Thanks & Regards,
Vikrant Sharma
1 ACCEPTED SOLUTION

But this method returns date and time for the begining of this month in GMT

 

find_real_file.png

-Anurag

View solution in original post

10 REPLIES 10

Thanks Shweta, We are on Europe/London, GMT doesn't consider daylight saving time. Everywhere else the time is fine, even while using other Date time functions, I have only noticed it while using beginningOfThisMonth

Please make it correct or helpful if this solves or help you with your issue for other to make use it.

Thanks & Regards,
Vikrant Sharma

Anurag Tripathi
Mega Patron
Mega Patron

That is probably beause of timezones, difference between GMT and UTC. London is on BST at this time of the year. 

-Anurag

Thanks Anurag, But I don't have any issue with the nowDateTime() function. It given me an hours difference with beginningOfThisMonth(). 

Please make it correct or helpful if this solves or help you with your issue for other to make use it.

Thanks & Regards,
Vikrant Sharma

But this method returns date and time for the begining of this month in GMT

 

find_real_file.png

-Anurag

Thanks Aurag, That makes sense as it suggest and correct me if I am wrong, that it should return the result in GMT, regardless of the system property? And, if I set the system property as GMT, instead of Europe / London, the results are below:

 

*** Script: Beginning of the month: 2018-07-01 00:00:00
*** Script: Get the current time: 23/07/2018 12:50:12

The current time goes out of sync, which makes sense, as GMT would be 1 hour behind BST(British Summer Time).
Cheers.
Please make it correct or helpful if this solves or help you with your issue for other to make use it.

Thanks & Regards,
Vikrant Sharma