10 examples of 'javascript get date without time' in JavaScript

Every line of 'javascript get 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
90function longdate(date, showtime) {
91 return format_date(date, months, showtime)
92}
14function getTime() {
15 var date = new Date();
16 var year = ("0000" + date.getFullYear()).substr(-4);
17 var month = ("00" + (date.getMonth() + 1)).substr(-2);
18 var day = ("00" + date.getDay()).substr(-2);
19 var hour = ("00" + date.getHours()).substr(-2);
20 var minute = ("00" + date.getMinutes()).substr(-2);
21 var second = ("00" + date.getSeconds()).substr(-2);
22 var millisecond = ("000" + date.getMilliseconds()).substr(-3);
23 return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second + "." + millisecond;
24}
21function getLocalTime (date) {
22 const year = date.getFullYear()
23 const month = date.getMonth() + 1
24 const day = date.getDate()
25 const dayOfWeek = date.getDay()
26 const hours = date.getHours()
27 const minutes = date.getMinutes()
28 const seconds = date.getSeconds() || 0
29 const milliseconds = date.getMilliseconds() || 0
30 return { year, month, day, dayOfWeek, hours, minutes, seconds, milliseconds }
31}
37function displayDateTime(time) {
38 if (time)
39 return time.replace('T', ' ').replace('.000Z', '');
40 else
41 return time;
42}
65function getDateObj(myDate: any): Date | null {
66 if (myDate == null) {
67 return null;
68 }
69
70 if (myDate instanceof String || typeof myDate === 'string') {
71 return new Date('' + myDate);
72 }
73
74 // A Firebase Timestamp format
75 if (myDate && (myDate.seconds >= 0 || myDate.seconds < 0) && (myDate.nanoseconds >= 0 || myDate.nanoseconds < 0)) {
76 return new Date(myDate.toDate());
77 }
78
79 return myDate;
80}
55public getDateString(): string {
56 return "" + this.day + "." + this.month + "." + this.year + ".";
57}
182private getDate (start: number, useUtc: boolean): Date {
183
184 // = 20150417
185
186 const n: number = this.buffer.getWholeNumber(start, start + 7)
187 if (n == null) {
188 return null
189 }
190 const monthDay: number = n % 10000
191 const month: number = Math.round(monthDay / 100)
192 const day: number = monthDay % 100
193 const year: number = Math.round(n / 10000)
194 let t: Date
195 if (useUtc) {
196 t = new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0))
197 } else {
198 t = new Date(year, month - 1, day, 0, 0, 0, 0)
199 if (this.adjustLocal) {
200 t = new Date(t.getTime() - t.getTimezoneOffset() * -60000)
201 }
202 }
203 return t
204}
37function getDate(strDate) {
38 /* istanbul ignore next */
39 return moment(strDate).format('YYYY-MM-DD')
40}
66function getCurrentDate() {
67 date = $("#date-picker").val();
68 time = $("#spinner").val();
69 millis = Date.parse(date + " " + time + " GMT");
70 return new Date(millis)
71}
30function GetTime()
31{
32 var date = new Date();
33 var timestamp = AddZeros(date.getDate()) + "/"
34 + AddZeros(date.getMonth() + 1) + "/" + date.getFullYear() + " "
35 + AddZeros(date.getHours()) + ":" + AddZeros(date.getMinutes()) + ":" + AddZeros(date.getSeconds());
36
37 return timestamp;
38}

Related snippets