Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
how to display json date in timestamp format in html

I need to convert json date time to string and write it html table cell. Json I am getting is like this:

 "creation": {
        "date": {
            "year": 2022,
            "month": 1,
            "day": 9
        },
        "time": {
            "hour": 10,
            "minute": 14,
            "second": 11,
            "nano": 830000000
        }

I want to display it like this : 1-9-2022 10:14:11:83000000 Is there built-in function in JS. Your help appreciated

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can create your own function using template literals, check the doc https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

const creation = {
  date: {
      year: 2022,
      month: 1,
      day: 9
  },
  time: {
      hour: 10,
      minute: 14,
      second: 11,
      nano: 830000000
  }
}

const renderTimestanp = ({date, time}) => `${date.month}-${date.day}-${date.year} ${time.hour}:${time.minute}:${time.second}:${time.nano}`

// will return 1-9-2022 10:14:11:83000000
renderTimestanp(creation)

about 4 years ago · Juan Pablo Isaza Report

0

There is no such build in function, but simple string concatenation will work:

var time = {
  "creation": {
    "date": {
      "year": 2022,
      "month": 1,
      "day": 9
    },
    "time": {
      "hour": 10,
      "minute": 14,
      "second": 11,
      "nano": 830000000
    }
  }
};

console.log(
  '' + time.creation.date.month + '-' + time.creation.date.day + '-' + time.creation.date.year +
  ' ' +
  time.creation.time.hour + ':' + time.creation.time.minute + ':' + time.creation.time.second + ':' + time.creation.time.nano
);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!