#1
  1. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221

    Issue with moment.tz


    Hello;

    I use Moment => https://github.com/moment/moment

    It'a pretty easy to use and works fine.

    The way I use it is by passing a date, time and timezone.

    Here is the code that works well.

    Code:
    Function updateCountdown() 
          {
            <?php //$t = 2018-05-10 00:00?>
            var date = moment.tz("<?php echo $t;?>", some_php_timezone);
            $clock.countdown(date.toDate());
          }
       updateCountdown();
    Now sometimes I get a warning in console
    moment construction using a non-iso string is deprecated
    I googled and this came up => LINK <=

    It hasn't listed the format I am using. Is it ok the way I am using it?

    Thanks
  2. #2
  3. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    You're getting a warning message and you want to know if what you're doing is okay?

    Moment wants a standardized string format, like the one created by date("c"), or for you to tell it what format you're using.
  4. #3
  5. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    Originally Posted by requinix
    tell it what format you're using.
    Hello;

    How can I tell it what format I am using?

    I saw this in the docs

    Code:
    moment.tz("2014-06-01 12:00", "America/New_York");
    I wanna use this format: YYYY-MM-DD HH:mm

    Code:
    var my_time = "2018-05-09 23:00";
    
    var timezone = 'Australia/Sydney';
    
    var date = moment.tz(my_time, timezone);
    How do you do it?

    EDIT;

    This also seems to work
    Code:
    var date = moment.tz("<?php echo $offer_open_date_time;?>", "YYYY-MM-DD HH:mm", timezone);
    Last edited by English Breakfast Tea; May 9th, 2018 at 07:21 PM.

IMN logo majestic logo threadwatch logo seochat tools logo