Dates and times

From SocialStack

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);