Search code examples
loopbackjsstrongloop

How to format a datetime literal in the StrongLoop API Explorer?


The documentation for the API Explorer is practically non-existent. One of my models requires a date property. The example given in the API Explorer looks like this: '2016-03-27'. How can I add a time to that?

Keep in mind I just need a datetime literal to enter into the API Explorer, not any JavaScript code.


Solution

  • I couldn't locate any documentation either. Based on a guess, I tried out some of the dateString literals that Date.parse() would parse successfully and found it to be working as expected with loopback. I used the example string formats from here.

    For example, I used the following dateString for the created field in the API Explorer for a POST \Users request:

    javascript { "email":"[email protected]", "password":"pass123", "created":"Mar 24, 2016 04:00:00 GMT" }

    The response contained this:

    javascript "created" : "2016-03-24T04:00:00.000Z"

    I also noticed that, similar to what is described in the link pasted, the Date defaults to local timezone if not explicitly stated.