Same Date field returns different Date formats?

Posted by Rollbase User on 30-Jan-2011 17:43

I have an object with a field of type Date. When I use the field in a trigger, it returns a date using this format: "Sun Jan 05 2011 00:00:00 (EDT)". var d = new Date("{!mydate}"); // Sun Jan 05 2011 00:00:00 (EDT) return d.getDate(); // will return 5 However, when I use the field in a "server-side validation" or in a template, it returns a date using this format: "dd/mm/yyyy". var d = new Date("{!mydate}"); // 05/01/2011 return d.getDate(); // will return 1 instead of 5 My scripts run as-is within triggers, but I need to reformat the date with server-side validations or templates. Shouldn't it behave the same way it all cases?

All Replies

Posted by Admin on 30-Jan-2011 18:26

1, Sun Jan 05 2011 00:00:00 (EDT) - this is JavaScript format, which should be always used in any JavaScript

2. 05/01/2011 - this is user-selected format for UI and templates.

I just verified that Server-side validation uses JavaScript format. Can you provide steps to reproduce the problem? Please submit support request to follow-up.

Posted by Admin on 30-Jan-2011 21:01

Done. I submitted a ticket with a test object.

Posted by Admin on 17-Jul-2011 10:32

The problem still exists. The JavaScript date format is not properly returned within:

- Script Components

- Fields of type Template

- Fields of type Email Template



I updated the ticket.

Posted by Admin on 17-Jul-2011 10:51

UI Script Components and Templates use HTML format, not JavaScript. So date is formatted according to user's preferences.

Posted by Admin on 15-Oct-2011 06:08

This problem is now solved.



I just need to add the suffix "#js" to my date token.

This way, it always returns a date in javascript format (instead of user's preferences format).



var d = new Date("{!mydate#js}");



PS: This is not yet documented in Rollbase in action

This thread is closed