We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22121
    • 2 Posts
    I have some code, mostly Javascript functions. It has one line of PHP in it. var servertimestring= ’<? print date("F d, Y H:i:s", time())?>’

    I have tried it in a Snippet and in a Chunk but it will not give the correct results.

    How do I bring this code into modx ?

    Thanks in advance..

    Chris
      • 10487 MODX Staff
      • 1,535 Posts
      Hi old_mac,

      I think the best bet would be to suck all the code into a snippet and insert the date there. (bearing in mind that snippets are executed as php code so you won’t need the php tags)

      Something like:
      ... some code ....
      
      $myJS = 'var servertimestring= \''. date("F d, Y H:i:s", time()).'\'';
      
      ... some code ...
      
      return $myJS;
      


      Hope that helps,
      Garry
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 22121
        • 2 Posts
        Works like a charm!

        thanks

        Chris