Timezone on date field value changes during test

I have a field called dob which represents date of birth of a user. I set it as a date field in the migration. There is a controller method that updates the field i.e UserController.updateDOB. I wrote a test to ensure the controller is working well, the date of birth supplied by user input works well but when I fetch the information from the database through the lucid model, it returns a date in a timezone that removes a day from the original date. I have tried using static castDates, static formatDates, and static get dates(), they are not fixing the problem.

I’ve found the issue. Those static functions I mentioned above run when you run model.toJSON() or when it’s serialized

1 Like