As it was a chat application I used momentjs for the timestamps on the messages, Everything was working fine locally, but when I deployed my app on Heroku I found that messages were not showing the correct time.
As the Heroku's default region is set to US & I was from India that was causing the issue. So basically momentjs was showing US Timezone.
So the problem was with Heroku's Timezone & Luckily Heroku allows us to change the timezone of our app just by simply adding a new config var.
After fixing the problem it was working fine :)
Here's the Solution:
1- Login into the Heroku from a browser
2- Select your app
3- Go to the setting tab
4- Press "Reveal Config vars" button
5- Set the keys to "TZ" and value of your timezone (Eg: Asia/Kolkata)
6- Press the add button
1- Open your Command shell
2- Login into Heroku
3- cd into your App directory
4- Setup TZ
heroku config:add TZ="Asia/Kolkata"
You can find your country's TZ value from this wiki page
India uses a single time zone for the whole country.
I looked on the Wiki page List of tz database time zones, but I was unable to find an entry for India.
If you can't find your country's TZ follow this link
Thanks for reading!