Date.prototype.startOf >= 0.1.4

Purpose

Set the current date to the start of a unit of time

Syntax

Date#startOf ( Stringunit );

Parameters

unit

Return values

Date

Returns itself

Examples

var a = new Date("2015-08-26T15:29:00.000Z");
>>> Wed Aug 26 2015 17:29:00 GMT+0200 (CEST)

a.startOf('hour');
>>> Wed Aug 26 2015 17:00:00 GMT+0200 (CEST)

a.startOf('month');
>>> Sat Aug 01 2015 00:00:00 GMT+0200 (CEST)