aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/src/utils/date.js
blob: de1d65e310d1007c1beb2ad71b6c050395eddb6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

/**
 * Format a date as 'YYYY-MM-DD'.
 *
 * @param {Date} date A date instance to format.
 * @return {string} 'YYYY-MM-DD'
 */
export function formatDateAsYMD(date) {
	const year = date.getFullYear()
	const month = (date.getMonth() + 1).toString().padStart(2, '0')
	const day = date.getDate().toString().padStart(2, '0')
	return `${year}-${month}-${day}`
}