Newer Version Available

This content describes an older version of this product. View Latest

startOf()

Returns a date that is the start of a unit of time for the given date.

Signature

startOf(string | number | Date date, string unit)

Parameters

date
Type: string | number | Date
A datetime string in ISO8601 format, or a timestamp in milliseconds, or a Date object.
unit
Type: string
A datetime unit. Options are 'year', 'month', 'week', 'day', 'hour', 'minute', or 'second'.

Returns

Type: Date
A JavaScript Date object. If a unit is not provided, returns a parsed date.

Sample Code

1var date = "2015-10-9";
2// Returns "Thu Oct 01 2015 00:00:00 GMT-0700 (PDT)"
3$A.localizationService.startOf(date, 'month');