How to correctly display time in javascript?

$(".test").each(function () {
    var _this = $(this);
    var time_utc = _this.data('time');
    var locale = $('html').data('lang') || 'en-us';
    var offset = moment().utcOffset();
    var time = moment(time_utc).add({ minutes: offset }).locale(locale);
    _this.text(time.fromNow()).attr('title', time.format("dddd, MMMM D, YYYY h:m a"));
  });

This will display the time adding three hours more than my country. How can I resolve this?

Example: Assuming I posted a comment on my website on January 27th at 9:42 am (local time) But on the website it says wrong: January 27 at 12:42…

date_default_timezone_set('america/chile');
$time = time();
$minutes_to_add = 0;
$DateTime = new DateTime();
$DateTime->add(new DateInterval('PT' . $minutes_to_add . 'M'));
$date = $DateTime->format('Y-m-d H:i:s');