We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8960
    • 150 Posts
    I would really love to change the MODx default date string from dd-mm-YYYY to mm-dd-YYYY.

    Any way to do this?
      • 8960
      • 150 Posts
      Would I have to modify just the MODx core .php pages? Is there a certain date string that’s commonly used throughout the site?
        • 10746
        • 126 Posts
        What do you mean by the default MODx date string? Do you mean in the manager?

        I don’t know anything for sure, but my quick examination of the files suggests that dates are produced by the various files making up the manager on a "per-file" basis and that you would have to track down exactly which file/script is producing the dates that you want to change...

        For example one place that produces dates is "System Info" (Reports ->System Info) and the dates are produced on line 109 of manager/actions/sysinfo.static.php where the PHP call strftime(’%d-%m-%Y, %H:%M:%S’... is used to format it. Change that line and then System Info works as you want... [file names/line numbers etc from 0.9.5RC2]

        But there are obviously many other places that use dates formatted differently, so you would have to track them down..

        I know that some other CMS (eg Drupal, I think but may be mis-remembering) use a common date format that you actually configure on set-up and is then used throughout the site... it would appear that this is not the case for MODx, although maybe this would be a nice feature.

        But again, remember that I know nothing for sure, so feel free to pick through the files yourself and experiment.

        HTH

        Gordon

          • 8960
          • 150 Posts
          I think the place where it’s bothering me the most is on the Publish/Unpublish dates for documents. The people I have that will be using MODx and not used to seeing dates in the dd-mm-YYYY format. This will create issues with me administering the site.

          Problem is, I’m afraid changing the date for Publish/Unpublish will be quite a bit more involved than for the System Info page.

          Ideally, I’d like to see the date change to a more international format, YYYY-mm-dd.
            • 10746
            • 126 Posts
            Quote from: er16004 at Dec 08, 2006, 10:59 PM

            Problem is, I’m afraid changing the date for Publish/Unpublish will be quite a bit more involved than for the System Info page.

            I don’t think it will be difficult... the output is always done with the function "strftime" which converts a timestamp to a formatted date..

            So it is only presentation that you need worry about, not actual DB storage, because this implies that relevant times are stored as "format-neutral" timestamps rather than in any particular format.

            A quick search shows that "actions/document_data.static.php" is responsible for listing the Publish/Unpublish dates on "Page Data".

            Actually I reckon you could just do a global search for "%d-%m-%Y" and change ALL of them.... in the manager they occur in the following files

            2 manager/actions/document_data.static.php:
            4 manager/actions/mutate_content.dynamic.php:
            3 manager/actions/mutate_user.dynamic.php:
            3 manager/actions/mutate_web_user.dynamic.php:
            1 manager/actions/sysinfo.static.php:
            2 manager/includes/datefunctions.inc.php:

            (ie 2 places in "manager/actions/document_data.static.php", 4 in "mutate_content.dynamic.php" and so on..)

            Only 15 to change... then you can let us know if it works smiley

            HTH

            Gordon

              • 8960
              • 150 Posts
              I am definitely going to try this. Thanks, Gordon!

              ER
                • 10357
                • 573 Posts
                Its better to change it in the snippets so you can upgrade easily. Snippets like ditto have a easy way to change the date string.
                  • 10746
                  • 126 Posts
                  Quote from: g5604 at Dec 09, 2006, 11:07 AM

                  Its better to change it in the snippets so you can upgrade easily. Snippets like ditto have a easy way to change the date string.

                  I don’t think that’s his problem... I *think* that he wants his "editor-users" who are using the manager to add content to see dates (such as publish/unpublish) in his chosen format...

                  These are hardcoded in the various files consistently using %d-%m-%Y..

                  Gordon
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    The Yanks have their dates backwards and use funny units of measurement, the Limeys drive on the wrong side of the road, and everybody else just talks funny! grin
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 8960
                      • 150 Posts
                      Quote from: gfroyle at Dec 09, 2006, 02:17 AM

                      Only 15 to change... then you can let us know if it works smiley

                      FYI: I just did a search in Dreamweaver, and there are 31 instances of %d-%m-%Y (on a fresh install of MODx 0.9.5).

                      I still haven’t had a chance to try this out, but I will today and report back.

                      Thanks!