Design and CSS styles
Version 5.x > Design and CSS styles > Date and Time Format View modes: 
User avatar
Member
Member
b.boughader-teleblue - 4/24/2012 5:48:32 AM
   
Date and Time Format
Hi Friends,

How can I format date and time using webpart "datetime" as following:
Tuesday, 24 Apr 2012 - 01:50:00 PM

Thank you

User avatar
Member
Member
kentico_michal - 4/24/2012 7:50:27 AM
   
RE:Date and Time Format
Hi,

The Date & time web part provides the property Date and time format that you can use to specify the format of the displayed date and time you require.

Anyway, the following format should display the date in the way you need:

Date and time format: "dddd, d MMM yyyy - H:mm:ss tt"

For more information about date and time format strings I would like to point you to this article: Custom date and time format strings

Best regards,
Michal Legen

User avatar
Member
Member
dilrukshanf-gmail - 5/22/2013 2:23:30 AM
   
RE:Date and Time Format
I have a similar problem were I need to add 'st', 'th' etc to the date. how can I do this on kentico ?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 5/22/2013 3:31:04 AM
   
RE:Date and Time Format
Hello,

As I mentioned also in the ticket...

Unfortunately, this functionality is not supported in .NET by default.

You will need to create a custom function for that: Adding custom functions to transformations

I've googled a little bit to provide you with some code examples how to achieve that:

1. http://stackoverflow.com/questions/5236223/formatting-a-datetime-value-day-value
2. http://forums.devshed.com/net-development-87/format-a-date-to-include-english-date-suffix-510236.html
3. http://www.wduffy.co.uk/blog/ordinal-suffix-datetime-extension-method/

If you will create a custom solution, feel free to share it :)

Best regards,
Martin Danko

User avatar
Member
Member
Pete - 10/15/2013 8:45:41 AM
   
RE:Date and Time Format
Hi,

for example in transformations for news you would do

FormatDateTime(Eval("NewsReleaseDate"), "dd MMMM yyyy - hh:mm:ss tt ")

Cheers