3

I am using AngularJS to get date from service 2014-09-29 and time as 191042 .

I need to show something like this

29 September 2014 19:10:42 ET

How do I convert it according to eastern time zone as I am getting date & time separately?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

1 Answers1

-1

You can format with a filter {{ date_expression | date : format : timezone}}, in your case: <span>{{datevar | date:'d MMMM y'}} {{timevar | date:'HH:mm:ss' : '-0500'}} ET</span> all the formats you find here: https://docs.angularjs.org/api/ng/filter/date. Check out at this plunker: https://plnkr.co/edit/l7ayOKSPGJp3Uvbfgtlx?p=preview. Completing the answer, if you need to ajust in summer time you can set the local with angular-locale plugin as you can see at this post: Angular JS - Date changes when submitting to $http - Timezone issue

Community
  • 1
  • 1
Luiz Rossi
  • 772
  • 5
  • 19
  • Thanks Luiz.But I have Date seperately and time seperately .I need to convert it according to eastern time and show as I described earlier – pourushsingh gaur Mar 01 '17 at 14:15
  • You can format separatedly, just the same way, you know wich timezone it is? I will ajust the answer for separated variables. – Luiz Rossi Mar 01 '17 at 14:18
  • I need to show according to EST – Eastern Standard Time – pourushsingh gaur Mar 01 '17 at 14:21
  • Eastern Standard Time (EST) is 5 hours behind Coordinated Universal Time (UTC). This time zone is in use during standard time in: North America, Caribbean, Central America. This time zone is often called Eastern Time Zone. – pourushsingh gaur Mar 01 '17 at 14:22
  • 1
    Note that this answer will be incorrect for half the year when EST becomes EDT. – Heretic Monkey Mar 01 '17 at 15:57
  • See, according to the question the answer is correct, and how can be known if the region change the timezone or not? other solutions may imply on servers or client clocks configuration, not on the script language. – Luiz Rossi Mar 01 '17 at 17:52