Difference between revisions of "Dates and times"
From SocialStack
(Created page with "Socialstack API's internally use UTC dates for essentially everything to simplify timezone behaviour. This is made more explicit by putting Utc on the end of all entity field...") |
|||
| Line 21: | Line 21: | ||
<Time absolute withDate date={thatDateNumberThing} /> | <Time absolute withDate date={thatDateNumberThing} /> | ||
</syntaxhighlight> | |||
If you would just like a raw JS date value, then the dateTools set of functions can help. They're used internally by UI/Time: | |||
<syntaxhighlight lang="jsx"> | |||
import {isoConvert} from 'UI/Functions/DateTools'; | |||
var jsDateUtc = isoConvert(entity.createdUtc); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 13:31, 15 November 2023
Socialstack API's internally use UTC dates for essentially everything to simplify timezone behaviour. This is made more explicit by putting Utc on the end of all entity field names. When the API serialises a date field, it serialises it as a UTC timestamp to eliminate ambiguity and simplify reading of the dates.
Working with dates on the UI
The Time component is the quickest way to display dates. By default it will display as a "time ago" view:
import Time from 'UI/Time';
<Time date={thatDateNumberThing} />You can display absolute dates like so:
import Time from 'UI/Time';
<Time absolute withDate date={thatDateNumberThing} />If you would just like a raw JS date value, then the dateTools set of functions can help. They're used internally by UI/Time:
import {isoConvert} from 'UI/Functions/DateTools';
var jsDateUtc = isoConvert(entity.createdUtc);