Basic Node and Express - Chain Middleware to Create a Time Server(2)

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

I’m getting:
the returned time is not between ± 20 secs from now;
I noticed that the new Date() returns GMT -0, which is not my browser time and for that reason the test might fail,
I read how to change it and managed to sync it as you can see below but it still won’t work.
Please advise…

req.time =  new Date(new Date().toString()+"-0300").toGMTString();
        function(req, res) {
  res.send({time: req.time});

new Date() Object automatically grabs current time based on your timezone. Therefore there is no need to add any string numbers for it. Go head and simply create a new Date. Then strigify it and save it in req.time.

req.time = new Date().toString();

it didn’t work at the first place when i used just “new Date()” , that’s the reason i started to complex everything

Any update on this? I’m having the same issue.

It’s a timezone issue in your PC, for me, I just set the timezone and time to automatic and that solve the issue.

My code was:

app.get('/now',(req,res,next)=> {
    req.time = new Date().toString();
  }, (req,res)=> {