2021年3月26日星期五

App is displaying wrong time on server but correct time on localhost?

My app basically sends out an email for a scheduled appointment with a start date and end date. On my local machine that is using Windows OS, it's sending out the correct time but on my ec2 ubuntu Linux server on AWS it is not and I'm not sure why...

An example that is displaying the wrong time is an appointment that is between 10:00AM - 10:30AM and this works fine on my localhost but when I console.log the start and end time it's displaying 5:00PM instead..

My Code below is exactly the same for localhost and what I pushed to my ubuntu Linux server but they're displaying different times.

What I want is to basically have that ISO 8601 time display correctly which is currently 10:00AM my time like on my localhost machine.

const express = require("express");  const bodyParser = require("body-parser");  const path = require("path");  const cors = require("cors");  var MetaTags = require("./metaTags");  var fs = require("fs");  const router = express.Router();  // loads .env file  const dotenv = require("dotenv");  const Moment = require("moment-timezone");    const config = dotenv.config({ path: path.join(__dirname, "../config/.env") });    // ISO 8601 Format  const randomDate = new Date("2021-03-27T17:00:00.000Z");    const correctDate = Moment(randomDate).format("MM/DD/YYYY h:ss A");    console.log("another date format is", correctDate);  // Logs 03/27/2021 10:00AM for start date... This is the correct time I want it to log like on my ubuntu Linux server...

What localhost is logging for the time:

enter image description here

What my ubuntu Linux server is logging for the time:

enter image description here

https://stackoverflow.com/questions/66827858/app-is-displaying-wrong-time-on-server-but-correct-time-on-localhost March 27, 2021 at 11:54AM

没有评论:

发表评论