Are you looking for customized advices? Click here to contact the expert!
by
6,450 23
0
5
385
1
Top 5% !
Popular
Tagged
Specified
OpenSource
Created
Modified Oct 26, 2017

Published on:

LanguageJavascript
LanguageNode

Get the current date and time

Get the current date and time
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2949337/Get-the-current-date-and-time?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
var datetime = ""; function getdate() { var currentdate = new Date(); datetime = currentdate.getFullYear(); datetime += "/"; if (currentdate.getMonth() < 10) { datetime += "0" + currentdate.getMonth(); } else { datetime = currentdate.getMonth(); } datetime += "/"; if (currentdate.getDate() < 10) { datetime += "0" + currentdate.getDate(); } else { datetime += currentdate.getDate(); } datetime += " "; if (currentdate.getHours() < 10) { datetime += " " + currentdate.getHours(); } else { datetime += currentdate.getHours(); } datetime += ":"; if (currentdate.getMinutes() < 10) { datetime += "0" + currentdate.getMinutes(); } else { datetime += currentdate.getMinutes(); } datetime += ":"; if (currentdate.getSeconds() < 10) { datetime += "0" + currentdate.getSeconds(); } else { datetime += currentdate.getSeconds(); } } getdate(); console.log("data e hora actuais: " + datetime);
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus