Reputation: 1414
I'm using
My data in the SQL looks like this:
+--------------+----+--------------------+
| date | id | happinessIndicator |
+--------------+----+--------------------+
| '2019-10-20' | 1 | happy |
| '2019-10-20' | 2 | happy |
| '2019-10-20' | 3 | happy |
| '2019-10-20' | 4 | happy |
+--------------+----+--------------------+
That's my code to get the votes of the current day
exports.day = function (req, res) {
const today = moment().format('YYYY-MM-DD');
knex('votes')
.where('date', today)
.then(function (resp) {
res.json({
status: true,
message: 'ok',
data: resp
})
})
.catch(function (error) {
res.json(
{
status: false,
msg: error.code
}
)
})
};
but my result looks like this:
Why doesn't he return 2019-10-20
like there is stored?
Upvotes: 0
Views: 501
Reputation: 1102
this is not an incorrect date, this is UTC format
.
you can set your own timzone format in your connection object lilke this:
knex({client,connection,useNullAsDefault: true,timezone: 'UTC',});
Upvotes: 2