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

I have completed all tests for this timestamp project besides the test ( Your project can handle dates that can be successfully parsed by new Date(date_string))

I am not sure why this does not pass and I am not even sure what the test is saying. Can someone please help .

// This takes a timestamp with an empty parameter and returns the current time since no date is there
app.get("/api/timestamp", function (req, res) {
  // Make sure variables are inside the function so the update everytime website is refreshed.
  let currentTime = Date().toString();
  let currentUnixTime =;
  res.json({ unix: currentUnixTime, utc: currentTime });

app.get("/api/timestamp/:date", function (req, res) {
  let date_string =;
  let date;

  // Create a js date if it is passed in year-month-day format
  if (date_string.includes("-")) {
    date = new Date(date_string);
  // Create a js date if it is passed in unix format
  else {
    let millisecondDate_string = parseInt(date_string); // First convert data_string to milliseconds (needs to be converted into a number as Date() will only accept unix as a number)
    date = new Date(millisecondDate_string); // Set the date in variable

  // Handles if date input is invalid
  if (date == "Invalid Date") {
    res.json({ error: "Invalid Date" });

  // Handles if date is valid
  else {
      unix: date.valueOf(), 
      utc: date.toUTCString(), 

Here is a link to my code:


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15.

Challenge: Timestamp Microservice

Link to the challenge:

Hello there,

This is what the test is doing:

(getUserInput) =>
  $.get(getUserInput('url') + '/api/timestamp/05 October 2011').then(
    (data) => {
        data.unix === 1317772800000 &&
          data.utc === 'Wed, 05 Oct 2011 00:00:00 GMT'
    (xhr) => {
      throw new Error(xhr.responseText);

This is your app’s response:

{"unix":5,"utc":"Thu, 01 Jan 1970 00:00:00 GMT"}

Hope this helps


Ahhhhh, that makes sense. All I had to do after you telling me this was to change the if logic to parseInt(dateString) < 10000. This way the 05 in front wouldn’t go to unix date in the else statement. It has now passed. Thank you for explaining the test to me! You saved me hours of time!

1 Like

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