How to get timezone with getDatePattern

I’m trying to get the timezone with getDatePattern,
I have a provider, this is the code that I have in it:

import { HttpClient } from ‘@angular/common/http’;
import { Injectable } from ‘@angular/core’;
import { Globalization } from ‘@ionic-native/globalization’;

export class TimezoneProvider {
public segundos :any;

constructor(public globalization: Globalization) {}


this.globalization.getDatePattern (  
  { formatLength: 'short', selector: 'date and time'} )
  .then(res => {
     let seconds = res.utc_offset;
      this.segundos = seconds;

  return this.segundos


in the page where I using the provider,
the variable is shown undefined

constructor(public navCtrl: NavController, public alertCtrl: AlertController, public timeZone:TimezoneProvider) {

      this.segundosTimeZone = this.timeZone.getTimeZone();


Recommend to use moment.js.
let offset = moment().utcOffset();

It has ton of useful time/date features ( plus, super simple ).

1 Like

Thank you so much!!! It Works.

import { Globalization } from ‘@ionic-native/globalization’;

This plugin is depricated now.