I want to display dates based on the users' time zones.
I am hoping that Angular provides a way to globally configure the Date
filter for this purpose. Doing it manually for each case doesn't seem right to me.
My timestamps are already passed through a timestamp()
function (which simply multiplies by 1000), but I'd rather not make changes to that function unless it's absolutely necessary.
Update:
I have implemented the following solution and it's working, but I would prefer a method to configure this at a higher level if possible.
$scope.timestamp = function (unix_time) {
var epoch = (unix_time * 1000);
var date = new Date();
var localOffset = (-1) * date.getTimezoneOffset() * 60000;
var stamp = Math.round(new Date(epoch + localOffset).getTime());
return stamp;
};