Back End Development and APIs Projects - Timestamp Microservice

Tell us what’s happening:
I cannot pass 3 tests:

  • Your project can handle dates that can be successfully parsed by new Date(date_string)
  • An empty date parameter should return the current time in a JSON object with a unix key
  • An empty date parameter should return the current time in a JSON object with a utc key

I debug by logging the date parameter and the output. They seemed fine.

  • “05 October 2011, GMT” input gives the correct output
  • blank date gives the current date

How do I pass these tests? Please kindly help.

Your project link(s)

solution: timestamp-service - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

I adjusted how the output is processed from .toLocaleDateString() to .toUTCString(). Now only the last 2 tests cannot pass.

Visually the 2 methods give the same output, not sure what the tester is looking for.

The tester expects the date to be the same as the local date on your computer, but new Date() will create a date based on current UTC time. That means that, depending on your local time zone, sometimes the UTC date could be one day before or after.

You will need to adjust the date saved on your server according to your local time zone. Unfortunately, there is no way to automatically get that information from the client, so you will need to hard-code it.

1 Like

These tests do not have the time zone offset problems that the exercise tracker tests have.

I just forked and ran the tests and all passed.

Thanks. I’ll try test it again on another PC. This PC’s time is a little off.

How do I hard-code it? I tried a few ways it didn’t work.

Update: it was my PC clock not match with actual time. Tried on another PC and passed.

try not to add data string because the api has a 50/50 it right or not

hey do you know if these codes are right for moving.

forward
controll_w(forward).(speed0.5).null

backward
controll_z(backward).(speed0.5).null

sideways
controll_a(turnleft).(speed0.3)

sideways
controll_s(turnright).(speed0.3)

thx

Please don’t spam other people’s topics.