-
☆ A M B ☆
- 24,524 Posts
The MODx variable for that is [*createdon*], but since that’s a UNIX timestamp you don’t want to use it. Ditto has a placeholder [+date+] that converts the create date to a human-readable form, and you can specify the exact format you want to use with the &dateFormat parameter in the snippet call, using any
PHP valid strftime option.
You can also tell Ditto to use the publish date or the last edited date instead of the createdon date.
http://ditto.modxcms.com/files/snippet-ditto-php.html#dateSource
Thank you for replying Susan.
I’m not quite sure if your response answers my question though. I’ve tried using [+date+] without success, I think because I’m not using it within a Ditto call. Although I’m using Ditto on the home page to show the news items (and I’ve used [+date+] and dateFormat here), I’ve just set up a link to each news story (which is essentially just a modx page). [*createdon*] shows a series of random number (the UNIX timestamp I presume) but I’m not sure how this can be converted in my case.
Could you show me an example please?
Thanks
Thanks for that.
I’m still not sure how to use the code above though. I’ve created a snippet with the PHP code in, and named it ’date-converter’.
Where do I put the DateFormatter call? And do I need to call &tv_name anything in particular?
Please forgive my ignorance, I’m pretty new to modx!
Thanks
Thanks very much Bunky, it works like a charm!