0

I have an Rails/Grape API that uses PostgreSQL DB With my endpoints to POST, PUT and GET it takes a time format like

2:00pm 

and converts to

2000-01-01T14:00:00.000Z

No biggie here. The problem is when I tried to show this with my angularJS front end.

It shows the 2:00pm above as

6:00AM -0800, Jan 1, 2000 6:00:00 AM

-0800 is PST which is the correct timezone. I even set Heroku servers timezones by using

heroku config:add TZ="America/Los_Angeles" 

I tried to use angular and moment to to see it in realtime

<input ng-model="test_form" class="form-control" value="2000-01-01T14:00:00.000Z">
<h3>angular: {{test_form| date:'dd MMM yyyy - hh:mm a'}}
<br>moment: {{test_form | amDateFormat: 'M/D/YYYY h:mm:ss A' }}</h3>

and here are the output for 2000-01-01T14:00:00.000Z

angular: 01 Jan 2000 - 06:00 AM
moment: 1/1/2000 6:00:00 AM

I want it to show the formatted time 1/1/2000 02:00:00 PM

Any help will be much apreciated

Marrento
  • 329
  • 3
  • 16
  • Could this be related to how JavaScript structures time zone offsets differently, like in this question? http://stackoverflow.com/questions/21102435/why-does-javascript-date-gettimezoneoffset-consider-0500-as-a-positive-off – Pete Nov 05 '14 at 04:05
  • lost in translation, oops... can you state in brief in the end - actual/expected etc – harishr Nov 05 '14 at 05:50
  • @harish the expected should be same as record saved. If 2000-01-01T14:00:00.000Z we want to display 2:00pm – Marrento Nov 05 '14 at 15:29

0 Answers0