On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hello,

    I am attempting to build a calendar system using a Bootstrap 3 (and 2) JavaScript calendar.

    I plan to use Resources (in combination with Collections) to build events and use getResources to build out the appropriate JSON file that the Calendar gets it's events from.

    A typical example of a JSON event is:

    {
     "id": "293",
     "title": "This is information class event",
     "url": "http://www.example.com/",
     "class": "event-info",
     "start": "1362938400000",
     "end":   "1363197686300"
    }
    


    Easy enough to use Resource and template variables to build this but, not being a programmer, I'm not sure how to convert the value of the Date TVs into milliseconds, as required in the JSON entry for each event.

    If I select say February 16, 2014, 12:00pm using a Date type TV with an output to default I get:

    2014-02-16 12:00:00

    Which is great of course.

    Setting the output to default I know we can use the typical %Letter syntax, but I don't see how to use that to create a millisecond output.

    Any suggestions?

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      try

      [[+yourTV:strtotime]]000
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • That's it, thank you. It was off by 1 hour according to a millisecond converter site.

        The output was: 1392573600000 which translated to: Sun Feb 16 2014 13:00:00 GMT-0500 (Eastern Standard Time).

        So I suspected it was a date_timezone system/context setting issue.

        Set a context setting of date_timezone to US/Eastern and the result now is: 1392570000000 which translates properly to: Sun Feb 16 2014 12:00:00 GMT-0500 (Eastern Standard Time).