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

    I have a bit of a strange one. Im redoing a site for a local church and currently bits of their site are all over the place. The idea is to have everything under one single roof for a more unified look and better feel.

    For the most part its coming together, but then I have the blog entries, which as far as their original created on date goes, causes some problems (news aswell thinking about this).

    If I create a blog entry it obviously assumes the date and time on which it was created. Looking in phpmyadmin att he table and field I was hoping to find a straight forward date format that I could change... but not so simple sad

    Instead I have a load of what appear to be random numbers

    For example created on is shown as 1234099573 (thats today) and shows like this in the blog 08-Feb-09 13:26.

    So how would I change this to display a custom date and time (possibly) so that when users come to the new site everything is still in its correct date order and archived properly?

    Many thanks,

    Tom.
      • 28033
      • 925 Posts
      I think it was DocManager that is extremely useful for this. I’m pretty sure that’s the name (it’s a module).
        My Snippets
        -> PopUpChunk v1.0
        • 16278
        • 928 Posts
        Not so random - 1234099573 and suchlike in the createdon and other MODx built-in date fields are Unix timestamps, the number of seconds since the "Unix era" of 1st January 1970 (see http://en.wikipedia.org/wiki/Unix_time for details, http://www.onlineconversion.com/unix_time.htm for a handy converter. 1234567890 is Fri, 13 Feb 2009 23:31:30 GMT). There’s a long thread somewhere in the forums debating the pros and cons of storing dates in this format, dwelling mainly on the ease of sorting by a simple incrementing pure number, as opposed to more human-readable formats such as YYYY-MM-DD.

        A number of PHP date and time functions are based on Unix timestamps, such as strftime(format string, timestamp), and strtotime(date string), which can translate between a wide variety of standard date descriptions and timestamps.

        Ditto expects to receive date parameters such as &orderBy and &dateSource as timestamps, and will translate the latter for display into the format given in &dateFormat. (see http://uk.php.net/strftime for format specifiers). So if you have docs with createdon as timestamps and you’re using Ditto, you can use parameters such as &dateFormat=`%d %b %y` to set the format to display createdon (the default for &dateSource). In your template, [+date+] is the placeholder for the resulting date string.

        You don’t say how the original blog was built or how you’re converting the entries, but I hope this of some help.
        KP
          • 3749
          • 24,544 Posts
          Tom, it looks like what you want would be accomplished just by preserving those dates. Most operations you’d do on those pages won’t change the createdon date unless you actually paste the content into a new document (which shouldn’t be necessary since it sounds like the documents are already in the DB).
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 11041
            • 82 Posts
            Hi all,

            Sorry I havent responded till now. Manic times lol.

            My reasoning for changing the dates are that visitors to the site browse through the posts and news via dates. So if they wanted to show a family member an article or blog post then going by date would work. If I manually input every post however the created on date would be out by however ever long it was since the actual post was made to the time I re put it into ditto and modx.

            In short really, when I come to use the calender style or even perhaps the month/yr menu on the side I want people to see back to say 1997 when a post was made as apposed to them all appearing as being created in Feb 2009.

            So would there be any harm in me fiddling with the "seconds since the 1st Jan 1970" unix timestamp? Im assuming it will give me the desired effect its just the calculations really.

            Regards,

            Also many thanks for the responses so far.
              • 11041
              • 82 Posts
              AhhI think I answered my own question.

              Cheers Keith for the useful link to the converter smiley