We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 686
    • 24 Posts
    Hi,

    I’ve been looking for an easy way of getting the Date Formatter widget (for TVs) to display in my local locale but I can’t seem to find a good solution.

    If there isn’t, I was thinking I could maybe do a snippet that reads the date TV and outputs the date in the correct locale. Can anyone offer any advice on this?

    Thanks
      • 29552
      • 6 Posts
      Did you finally find a solution or not ?

      Like this it looks like there’s no community around ModX wich is a bit scary.
      Please update your thread dudes.
        • 686
        • 24 Posts
        Yeah, sorry. I guess I should have followed up on this.

        I ended up writing some code that reads the TV value and re-orders the date so that strtotime() could be used:

          $year = substr($event_date,6,4);
          $month = substr($event_date,3,2);
          $day = substr($event_date,0,2);
          $time = substr($event_date,11,8);
        
          $widget_date = strtotime($year . '-' . $month . '-' . $day . ' ' . $time); // ...and Bob's your uncle!
        
        


        The TV’s value gets put into $event_date by a function I wrote myself as couldn’t get the MODx function to work. But it does work (when I tried it again later).

        Hope that helps.