Get the current date and time in deno using the datetime module
1
// import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
2
3
import { format } from "https://deno.land/[email protected]/datetime/mod.ts";
4
5
export async function main() {
6
// current date in YYYY-MM-DD format
7
console.log(format(new Date(), "yyyy-MM-dd"));
8
9
// current date & time in YYYY-MM-DD hh:mm:ss format
10
console.log(format(new Date(), "yyyy-MM-dd HH:mm:ss"));
11
12
// current time in hh:mm format
13
console.log(format(new Date(), "HH:mm"));
14
}
15