W3cubDocs

/date-fns

startOfDay

Return the start of a day for the given date.

Description

Return the start of a day for the given date. The result will be in the local timezone.

Usage

// CommonJS
var startOfDay = require('date-fns/startOfDay')
// ES 2015
import startOfDay from 'date-fns/startOfDay'
// ESM
import { startOfDay } from 'date-fns'

Syntax

startOfDay(date)

Arguments

Name Description
date

the original date

Returns

Description

the start of a day

Exceptions

Type Description
TypeError

1 argument required

Examples

// The start of a day for 2 September 2014 11:55:00:
const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
//=> Tue Sep 02 2014 00:00:00

© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/startOfDay