I'm facing some issue trying to use moment.js
for dealing with time offsets.
I collect in an hidden input the local user time offset:
<script type=text/javascript>
$(document).ready(function () {
$('input#timeoffset').val(moment().utcOffset());
});
</script>
The offset gets correctly stored (in my case its value is -240). Later on the server side (which runs in utc time) I try to update some db stored utcDate doing something like:
var userDate = moment(utcDate).utcOffset(offset)
My issue is the following:
if I run my code as above described I get no effects:
utcDate: 20151001 012421 +0000
userDate: 20151001 012421 +0000
If I flip the offset sign I get:
utcDate: 20151001 012421 +0000
userDate: 20151001 052421 +0400
I'm clearly doing something wrong (even if my expectation was that the first version was correct), do you have any hint?
On client-side I'm using moment.js v2.10.6 while on the server-side moment-timezone.js v0.4.0 and moment.js v2.10.6