var date = Model.GetPropertyValue<DateTime>("dateInputGoesHere");
(this may be some different syntax depending on the type of razor you are using) but you mainly need to render the item as a DateTime to be aloud to use the .ToString below.
var date = Model.Content.GetPropertyValue<DateTime>("pageDate");
if (date != DateTime.MinValue)
{
<small>@date.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture)</small>
}
Date - time datatype output
Hej
Is there a way to change the time format from:
9/13/2017 2:30:00 PM
to
9/13/2017 14:30 PM ??
Hi Thomas,
Maybe this might work for you:
string formatted = dt_calc.ToString("HH:mm:ss");
and if you using some custom data you should definitely look up Microsoft documentation on custom Datetime. https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
Hi Thomas,
You could do the following:
When retrieving the date from your cms:
(this may be some different syntax depending on the type of razor you are using) but you mainly need to render the item as a DateTime to be aloud to use the .ToString below.
You can read up on date formatting here: https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.80).aspx
If you show me some code samples you are working with I can try to resolve them for you.
Thanks, Lewis
Thanks,
ended up doing it like you showed!
In Umbraco 8 you can get the formatting from https://momentjs.com/
Then use something like;
is working on a reply...