I have this date: 1386800070703
. Let's say it's UTC.
How can I tell angular what timezone it is and in what timezone I want it displayed?
I'm currently using tihs which only converts it without any timezone info:{{1386800070703 | date:'d MMMM yyyy'}}
And would like to be able to show a timezone to the right of the date.
Navigate to a PivotTable or PivotChart in the same workbook. Add a column from the Date table to the Column Labels or Row Labels area of the Power Pivot field list. Click the down arrow next to Column Labels or Row Labels in the PivotTable. Point to Date Filters, and then select a filter from the list.
Example: Date Filter The Date column is using a Date Filter. A custom comparator is provided to parse the data and allow date comparisons to be made. The native date picker is forced to be used in every browser. The minimum valid year is set to 2000 , and maximum valid year is 2021 .
In the next version of AngularJS (1.3.0) you can specify the timezone this way:
{{someDate | date:'d MMMM yyyy Z' : 'UTC'}}
Currently, only supports UTC, as you can see in the docs: https://code.angularjs.org/1.3.0-rc.2/docs/api/ng/filter/date
You can play with it here: Plunker example
Notice, the time zone will be shown as local-time even if specified otherwise.
Here's a directive I wrote that does just that:
angular.module('CommonDirectives', []).directive('adjustTimezone', ['$filter', function ($filter) {
return {
restrict: 'A',
scope: {
adjustTimezone: '@'
},
link: function ($scope, element, attrs) {
var date = new Date(attrs.adjustTimezone);
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
element.text($filter('date')(date, attrs.filter));
}
}
}]);
Here's how you use it:
<span data-adjust-timezone="{{date.MilitaryTime}}" data-filter="EEEE, MMMM d, y h:mm a"></span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With