0

Get Date & Time

by
Published Feb 3, 2023

Get the current date and time in deno using the datetime module

Script Helper
  • Submitted by aadarshkannan111127 Deno
    Created 1255 days ago
    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