10 examples of 'javascript today's date without time' in JavaScript

Every line of 'javascript today's date without time' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
6function getToday() {
7 var now = new Date();
8 now.setHours(0);
9 now.setMinutes(0);
10 now.setSeconds(0);
11 now.setMilliseconds(0);
12 return now;
13}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

43function getToday(){
44 var date = new Date()
45 var day = pad(date.getDate())
46 var month = pad((date.getMonth()+1))
47 var year = date.getFullYear()
48 return month + '/' + day + '/' + year
49}
235function formatTodayDate () {
236 const date = new Date();
237 const day = ('0' + date.getDate()).slice(-2);
238 const month = ('0' + (date.getMonth() + 1)).slice(-2);
239 const year = date.getFullYear();
240
241 return `${year}-${month}-${day}`;
242}
90function longdate(date, showtime) {
91 return format_date(date, months, showtime)
92}
362function preDay(date) {
363 return new Date(date.getTime() - 24 * 60 * 60 * 1000)
364}
86function getDate(date) {
87 var yyyy = date.getFullYear().toString();
88 var mm = (date.getMonth() + 1).toString();
89 var dd = date.getDate().toString();
90
91 return (dd[1] ? dd : "0" + dd[0]) + "." + (mm[1] ? mm : "0" + mm[0]) + "." + yyyy;
92}
388export function getFutureDate(days) {
389 const now = new Date();
390 now.setDate(now.getDate() + parseInt(days, 10));
391
392 return now;
393}
121export function getYesterday () {
122 return new Date(new Date() - 24 * 60 * 60 * 1000).toLocaleDateString().replace(/\//g, '-')
123}
1export function getPrevDate(date: Date): Date {
2 return new Date(date.getTime() - 24 * 60 * 60 * 1000);
3}
23public static getDate(currentDatePlusDays) {
24 const currentTimeInMs = new Date().getTime();
25 return new Date(currentTimeInMs + (currentDatePlusDays * DateHelper.dayDurationInMs));
26}

Related snippets