I have been looking through the list of available options for outputting the number of the current month, as usual way is (%m) but that outputs '01 – 09' where as I just looking for '1 – 9'. I have read through the standard PHP options and it says to use (%n), but that seems to just create a line break. anyone have any ideas how to output single digit dates if output filters like:
I have been looking through the list of available options for outputting the number of the current month, as usual way is (%m) but that outputs '01 – 09' where as I just looking for '1 – 9'. I have read through the standard PHP options and it says to use (%n), but that seems to just create a line break. anyone have any ideas how to output single digit dates if output filters like:
I believe that you need to use the stuff from strftime: http://php.net/manual/en/function.strftime.php Therefore there is no code for month without the leading zero. Not sure of how to approach this. I read something about a flag in there to remove.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
The MODX date output modifier uses strftime() as Jay suggests (instead of date(), which you'd expect), which has no single-digit month option.
Try %-m for the month. It won't work on Windows, but should on a linux server, and %-d should give you a single-digit day.
If that doesn't work, you'd have to create a custom modifier that uses PHP's date() function, but that won't respect any locale setting, which you'd need for a multi-language site.
thank you very much for your guys' help, that actually seems to work for my given situation. It just so happened that the particular JavaScript required single-digit inputs for the number of the month, so even if I didn't find a solution within PHP, I could easily (I hope) come up with a JavaScript solution. But this is good information for those people who might need to know in the future.