New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'S' is the ordinal suffix for day-of-the-month only. #8
Comments
Here's my test code:
|
One last thing: |
Hey there. Thanks for the note. I'll have a look for the correct transformations but that wont happen until next week. Would be great if you could figure out the correct formats and push them - in case you have some time. Cheers |
I'll see what I can do. Unfortunately there aren't any ordinal suffixes for anything but the day-of-the-month in PHP (as far as I can tell) so they (the suffixes) may have to be dropped during the conversion. |
echo date('dS M Y'); // 13th May 2014 Thats what u want, right? |
Ah, I see. U want something like:
correct? |
Well, it's not so much that I want it but rather that Moment.js supports that and PHP doesn't so you can't convert between the two. The 'S' in PHP is for day-of-the-month ONLY. There are no ordinal suffixes for day-of-the-year. This means that the aforementioned conversions don't work. |
But yes, it seems (as far as I can tell) getting something like: |
You can do this with PHP. If you know it's the 265th day of the year you want, you really only care about the 5 to get the correct S value. To get "th" you can use: If you wanted to get an "st" you can use: |
Thats what we want then: |
Perhaps I'm missing something, but that doesn't seem to solve the issue because we don't know what day it is. This issue is dealing with converting a moment.js date format string to a PHP date format string. |
Ok, I am just shooting quickly here but we have to do some logic here. If the user requests something with "o" I know that he wants some ordinal shizzle. "Mo" stands for month so we run in php "m" through the aforementioned function which would result in "05th" instead of only giving us back "05". Again, I am really just going by feeling right now since I am busy with some other stuff. Cheers from Berlin |
Yes, if you want ordinal suffixes for anything other than day-of-month you need extra logic. But that seems out of scope for the MomentJS.php class since it only handles format strings and not the dates themselves. SO, with regard to the MomentJS.php class: what should these conversions be?
|
version 1.5.0 has this now. just released it. |
In MomentJs.php you have listed conversions for the following momentJS format strings to their appropriate php format strings:
The only one of the above conversions that is correct is the 'Do' -> 'jS' conversion. According to the PHP docs, 'S' is the English ordinal suffix for the day of the month only.
Sources:
http://php.net/manual/en/function.date.php
The text was updated successfully, but these errors were encountered: