Javascript Node.js Basic Node App


Basic Node.js: A Simple App

A quick, little Node app that imports a library, asks for user input, modestly error checks and returns an adjusted date/time value.

Copy and paste the code below into a javascript file in a new node program in your environment. Don't forget you'll need to do the 'npm install.... ' as directed in the comments of the code.


//Before this will run, you'll need to do "npm install moment-timezone" from your command line

//require moment-timezone for timezone processing
const moment = require('moment-timezone');

//declare your default timezone'America/Denver');

//declare your targetTimeZone var
let targetTimeZone;

//app logic: when user calls this node app they have to use "node index.js America/Los_Angeles"
if(process.argv.length != 3) {
    console.log('Usage: node  ');
} else{

//console.log results
console.log(`The current time in ${targetTimeZone} is ${}`);

Link your website to this page! Copy and paste the URL below:
Copyright 2021. All Rights Reserved.