10 examples of 'how to get current date in jquery' in JavaScript

Every line of 'how to get current date in jquery' 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
66function getCurrentDate() {
67 date = $("#date-picker").val();
68 time = $("#spinner").val();
69 millis = Date.parse(date + " " + time + " GMT");
70 return new Date(millis)
71}
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

116export function currentDateTime(): ISimpleDateTime {
117 return dateToSimpleDateTime(new Date());
118}
308function CurrentDateTime() {
309 var currentdate = new Date();
310 var datetime = "Last Sync: "
311 + (currentdate.getMonth()+1) + "/"
312 + currentdate.getDate() + "/"
313 + currentdate.getFullYear() + " @ "
314 + currentdate.getHours() + ":"
315 + currentdate.getMinutes() + ":"
316 + currentdate.getSeconds();
317 return datetime;
318 }
12function getCurrentDate() {
13 var now = new Date();
14 return now.toISOString();
15}
19function getDate() {
20 // GET CURRENT DATE
21 var date = new Date();
22
23 // GET YYYY, MM AND DD FROM THE DATE OBJECT
24 var yyyy = date.getFullYear().toString();
25 var mm = (date.getMonth()+1).toString();
26 var dd = date.getDate().toString();
27
28 // CONVERT mm AND dd INTO chars
29 var mmChars = mm.split('');
30 var ddChars = dd.split('');
31
32 // CONCAT THE STRINGS IN YYYY-MM-DD FORMAT
33 var datestring = yyyy + '-' + (mmChars[1]?mm:"0"+mmChars[0]) + '-' + (ddChars[1]?dd:"0"+ddChars[0]);
34
35 return datestring ;
36}
19export function get_date(): number {
20 return Math.floor(Number(Date.now()) / 1000);
21}
37function getDate(strDate) {
38 /* istanbul ignore next */
39 return moment(strDate).format('YYYY-MM-DD')
40}
127export function getDate (date) {
128 return get(date, 'date')
129}
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}
7function getDate(){
8 d = new Date();
9 t = d.getTime().toString();
10 t = t.substring(t.length-4, t.length);
11 date = ((d.getFullYear())+'-'+(d.getMonth()+1)+'-'+d.getDate());
12
13 return date;
14}

Related snippets