In one of my Document Types, I have set up a Property named articleDate that is set to use a Date Selector/Editor. I've tried changing the format to DD-MM-YYYY and a number of other supported formats, but it always outputs like:
7/19/2018 12:00:00am
For reference, this is how I've rendered the property in the Template:
<p>@Umbraco.Field("articleDate")</p>
Am I missing something else that needs to be included?
Unfortunately setting the date format in the date datatype to a certain format for showing the dates in the backoffice does not mean it will be rendered in the same way when you render the output date. It only benefits the editors so they see the date in the correct format when editing the content.
When you render the date you will need to ensure that the date is rendered in the same format. This can of course seem a bit silly but depending on the circumstances you might want to show one format for the editors but will need to format it in different ways depending on whether you're doing a multi-language site where the displaying of the date format might differ for instance.
So as far as I know to achieve the rendering of the date that you want you will can do something like this:
Ok, if the HTML output you get is still showing the time then nothing makes sense to me anymore...since we specifically pass the formatting arguments...that's really odd... :-)
Just to make sure that I'm not misunderstanding you - Could you please post a screendump of what things look like on your document type where you specify the date in Umbraco?
And also a screendump of the frontend rendering of your website?
Unable to format Date Selector/Editor correctly
In one of my Document Types, I have set up a Property named articleDate that is set to use a Date Selector/Editor. I've tried changing the format to DD-MM-YYYY and a number of other supported formats, but it always outputs like:
7/19/2018 12:00:00am
For reference, this is how I've rendered the property in the Template:
Am I missing something else that needs to be included?
Thanks in advance!
Hi Stefan
Unfortunately setting the date format in the date datatype to a certain format for showing the dates in the backoffice does not mean it will be rendered in the same way when you render the output date. It only benefits the editors so they see the date in the correct format when editing the content.
When you render the date you will need to ensure that the date is rendered in the same format. This can of course seem a bit silly but depending on the circumstances you might want to show one format for the editors but will need to format it in different ways depending on whether you're doing a multi-language site where the displaying of the date format might differ for instance.
So as far as I know to achieve the rendering of the date that you want you will can do something like this:
I hope this helps!
/Jan
Thanks Jan, this worked perfectly!
Hi Stefan
Ok, if the HTML output you get is still showing the time then nothing makes sense to me anymore...since we specifically pass the formatting arguments...that's really odd... :-)
Just to make sure that I'm not misunderstanding you - Could you please post a screendump of what things look like on your document type where you specify the date in Umbraco?
And also a screendump of the frontend rendering of your website?
Cheers, Jan
Jan, my apologies, this actually worked. Will mark your response as the correct solution.
Thanks for your help!
Hi Stefan
Ahh, good to hear!
Happy coding :-)
/Jan
is working on a reply...