Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 5 of 5 total |
Date / Now |
Wed, Jan 30 2019 11:34 AM | Permanent Link |
Eivind | All
Just saw something odd today and maybe its designed this way. I'm setting a DateTimePicker.SelectedDate to todays date before showing the user the form. If I use DateTimePicker.SelectedDate := Date I get 29/01/2019 and if I use DateTimePicker.SelectedDate := Now I get 30/01/2019. When I test this its 30 minutes before midnight on the 30/01/2019 so I would expect the 30'th of Jan. However, before I have been using DateTimePicker.SelectedDate := Date and just now I saw the problem with the date. Its actually almost 31 Jan and still "Date" show 29'th Jan. Obviously I will continue to use "Now" to generate the date. Just wondered if this was as designed? Cheers Eivind |
Thu, Jan 31 2019 5:17 AM | Permanent Link |
Walter Matte Tactical Business Corporation | Eivind:
Timestamps are still Localized so - yes this is as designed. Here is how I work with Now..... function NowFix : DateTime; begin result := Now - (TimeZoneOffSet(now) * 60 * 1000); end; Walter |
Thu, Jan 31 2019 9:48 AM | Permanent Link |
Eivind | Walter Matte wrote:
<<<<<Timestamps are still Localized so - yes this is as designed.>>>>>> @Walter. Understood... According the the manual on Now is says: The Now function returns the current date and time. The return value is a DateTime value. So that is as expected. However, the Date function should only return a date and according to the manual is says: The Date function returns the current date. The return value is a DateTime value. So if I used the Date and not Now, should't that give me the correct Date independent of the timezone? However, the return is a DateTime value according to the manual. Does that means the time part would be 00:00:00 and localised because of that? Thanks for the modified Now function you mention! I will do some testing with that one to purely get the current date of the users computer independent of any timezones. |
Fri, Feb 1 2019 2:58 AM | Permanent Link |
ooptimum | << So if I used the Date and not Now, should't that give me the correct Date independent of the timezone? However, the return is a DateTime value according to the manual. Does that means the time part would be 00:00:00 and localised because of that? >>
According to sources: function date() { var $0 = new Date(); return new Date($0.getFullYear(), $0.getMonth(), $0.getDate(), 0, 0, 0, 0).getTime(); }; you will receive a date in UTC (GMT) with zero time. |
Fri, Feb 1 2019 2:34 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eivind,
<< Just saw something odd today and maybe its designed this way. I'm setting a DateTimePicker.SelectedDate to todays date before showing the user the form. If I use DateTimePicker.SelectedDate := Date I get 29/01/2019 and if I use DateTimePicker.SelectedDate := Now I get 30/01/2019. >> Make sure to turn off this property: https://www.elevatesoft.com/manual?action=viewprop&id=ewb2&comp=TCalendar&prop=LocalizeText or https://www.elevatesoft.com/manual?action=viewprop&id=ewb2&comp=TDateEditComboBox&prop=LocalizeText depending upon which control you're using. I need to remove that property in a new build because it doesn't apply to dates anymore now that EWB isn't localizing dates. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Thursday, March 28, 2024 at 06:05 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |