I don't think we can help with that. JavaScript Date object provides limited TimeZone -specific functionality. Please check http://www.w3schools.com/js/js_obj_date.asp for more details.
Pavel, are you saying that if I want to use Rollbase, I need to be in your time zone? Why is there a time zone setting in my preferences? Maybe you can have a API call GetLocalTime() which gets your time, compares timezones, and returns the local time? There are many saas systems that operate across time zones -- there must be a way to return the correct date?
What exactly seems to be the problem? There is one clock in the system (on server), but when it comes to displaying date and time resulting string is formatted according to user's time zone and selected format. In JavaScript API this should work the same way.
The fact that Date is using CDT should not concern you - this is for intermediate operations only. When it comes to actual display you should see correct result.
Maybe I'm looking at it wrong. I have a formula that looks like this:
if("{!status#value}" != "Outstanding")
return 4;
dt = new Date("{!due_date}");
today = new Date();
if(dt.getDate() == today.getDate())
return 2;
if(dt
return 1;
if(dt > today)
return 3;
the problem is that today is being assigned yesterday's date, so the wrong integer is being returned.
Actually, I just checked your rollbase formula guide, and the way you get your dates is exactly the same. This means that many of the date formulas in your guide will not work in different timezones. For example:
Days until a target date
This formula calculates the number of days between two dates and returns a String. If the target date is given by
the merge field {!targetdate}, the number of days can be calculated as follows:
var today = new Date();
var targetdate = new Date("{!targetdate}");
remaining = ((targetdate.getTime() - today.getTime()) / (24 * 60 * 60 * 1000));
remaining = Math.round(remaining);
return remaining + " days left";
this will not work because today variable is assigned yesterday's date, so remaining ends up 1 more than it should. Does this make sense?
Good point. We'll provide server-side API which will generate JavaScript Date object taking into account user's time zone.
terrific. thank you.
Hi Pavel. Did you implement this one yet?
The example above works fine for date/time values (I tried) since date/time is re-calculated to server time zone, so the difference is correct. However for date only value there may be a problem. I will need to provide an API for that.
I finally figured out (I think) how to deal with this issue. The following code should work:
var today = new Date(rbv_api.getCurrentDate());
var targetdate = new Date("{!targetdate}");
remaining = ((targetdate.getTime() - today.getTime()) / (24 * 60 * 60 * 1000));
remaining = Math.round(remaining);
return remaining + " days left";
API getCurrentDate generates a text string corresponding to current date and user's time zone. Field dates should include correct time zone as well, so no API is needed. Please try at your convenience. I'm updating documentation (Chapter 6).