What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-23 05:25:41
javascript current date time
var today = new Date(); var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate(); var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); var dateTime = date+' '+time; Add solution -
Javascript 2022-01-23 04:51:00
js get current timestamp
var timestamp = new Date().getTime(); Add solution -
Javascript 2022-01-23 02:05:39
javascript new function as class
// Javascript Function that behaves as class, with private variables function Person(name){ const birth = new Date(); this.greet = () => `Hello my name is ${name}. I was born at ${birth.toISOString()}`; } const joe = new Person("Joe"... Add solution -
Other 2021-11-21 22:10:24
save in local storage with expiration
function getWithExpiry(key) { const itemStr = localStorage.getItem(key) // if the item doesn't exist, return null if (!itemStr) { return null } const item = JSON.parse(itemStr) const now = new Date() // compare the expiry time of the item with th... Add solution -
Javascript 2021-11-21 19:31:21
calculate today date javascript
var today = new Date(); var dd = String(today.getDate()).padStart(2, '0'); var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! var yyyy = today.getFullYear(); today = mm + '/' + dd + '/' + yyyy; document.write(today); Add solution