Back End Development and APIs Projects - Timestamp Microservice

Tell us what’s happening:

Code contains solution.

Your project can handle dates that can be successfully parsed by new Date(date_string)

I have used this in my code multiple times yet the error occurs. Need Help!

let responseObject = {};

app.get('/api', (req, res) => {
  responseObject['unix'] = new Date().getTime();
  responseObject['utc'] = new Date().toUTCString();


app.get('/api/:date', (req, res) => {
  let date =;

    responseObject['unix'] = new Date(date).getTime();
    responseObject['utc'] = new Date(date).toUTCString();
  } else {
    responseObject['unix'] = Number(date);
    responseObject['utc'] = new Date(Number(date)).toUTCString();
  if(!responseObject['unix'] || !responseObject['utc']) {
    res.json({error: 'Invalid Date'});

Your project link(s)

solution: boilerplate-project-timestamp (1) - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

The following is a date that can be parsed by new Date():

05 October 2011

1 Like

I have done that. Here.
responseObject['unix'] = new Date(date).getTime();

I have tried this too.
responseObject['unix'] = new Date( '05 October 2011' ).getTime();

Not working.

Finally solved it! Thanks for your help.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.