Forum Discussion
_anomDiebolt_
10 years agoQrew Elite
One impediment I see to people not using the API and script more is that they don't understand how to deal with date fields. When a date field is returned from the API it is not human readable - rather it is presented as an integer repenting the number of milliseconds since the start of the Unix Epoch (midnight Jan 1, 1970). A typical date field returned by API_DoQuery might look like this:
1435579444018
Surprisingly, JavaScript does not have native features to convert this representation to a human readable format using patterns such as "mm/dd/yy". In the past I have used the wonderful library datejs to convert and manipulate dates:
https://github.com/datejs/Datejs
But it is just another library to load and in my work on the General Record Picker I wanted my interface to be screaming fast but still be able to format dates using the convenience of a library. Well it turns out that QuickBase uses the jQueryUI library on its forms and the date widget has methods to convert a date from the raw millisecond to a human readable format:
>$.datepicker.formatDate("mm/dd/yy", new Date( parseInt("1435579444018" ,10)) );
>"06/29/2015"
Since this library is already loaded on QuickBase's pages you may as well use it. Here are the docs which show the wide range of human date formats you can generate:
jQueryUI FormatDate Utility method
https://api.jqueryui.com/datepicker/#utility-formatDate
1435579444018
Surprisingly, JavaScript does not have native features to convert this representation to a human readable format using patterns such as "mm/dd/yy". In the past I have used the wonderful library datejs to convert and manipulate dates:
https://github.com/datejs/Datejs
But it is just another library to load and in my work on the General Record Picker I wanted my interface to be screaming fast but still be able to format dates using the convenience of a library. Well it turns out that QuickBase uses the jQueryUI library on its forms and the date widget has methods to convert a date from the raw millisecond to a human readable format:
>$.datepicker.formatDate("mm/dd/yy", new Date( parseInt("1435579444018" ,10)) );
>"06/29/2015"
Since this library is already loaded on QuickBase's pages you may as well use it. Here are the docs which show the wide range of human date formats you can generate:
jQueryUI FormatDate Utility method
https://api.jqueryui.com/datepicker/#utility-formatDate
WendyShoef
7 years agoQrew Cadet
Worked perfectly for what I needed. Thanks!