We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    This is a common scenario: we have a TV that uses the Date input type to allow us to click a Javascript calendar with a desired date, then we use a Ditto call to reference and format that date. This requires that the template variable uses the "Unixtime" widget, and that our Ditto tpl uses the [+date+] to display the formatted date.

    E.g.
    #Ditto Call:
    [!Ditto?startID=`2` &dateSource=`myTV` &dateFormat=`%d-%b-%Y` &tpl=`myTpl`!]
    
    #tpl:
    <p>This record references [+date+]</p>
    


    But the dates are wrong... specifically, it seems that the unix timestamps returned by the Unixtime widget are wrong... the TV stores a date like ’01-04-2010 00:00:00’, and it comes back in the formatted Ditto results as being 2006. The Unixtime widget changes ’01-04-2010 00:00:00’ to 1159686000, but it should be 1270105200 -- I’ve tested this using the strtotime() function. It seems like the code in

    ./manager/includes/tmplvars.format.inc.php

    may be to blame. This is on a 1.0.2 install. Anyone else had this problem?
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Anybody?
        • 26931
        • 2,314 Posts
        Hi Everett,

        i’ll check if i get the same behaviour

        does it make a difference if you use [+myTV:date=`%d-%b-%Y`+] instead of [+date+]?

        [+date+] will also throw an error if you’re using a server offset time btw.: http://modxcms.com/forums/index.php/topic,35089.msg218577.html#msg218577