Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > how to custom format datetime using eval. View modes: 
User avatar
Member
Member
jp.principio.mail-gmail - 9/29/2011 12:31:27 AM
   
how to custom format datetime using eval.
Hi,

as the subjects says, how can I custom format (MMMM dd, yyyy) the datetime in blogpost using eval in cms_transformation.

I used <%# Eval("BlogPostDate", "BlogPostDate", "{0:dd MMMM yyyy}") %> but no luck.

I also used <%# Convert.ToDateTime(Eval("BlogPostDate").ToString("MMMM dd, yyyy") %> but still no luck.

I used <%# Convert.ToDateTime(Eval("BlogPostDate").ToString("d") %> and it worked! but not my preferred format. :(

Thanks,

JP

User avatar
Member
Member
jp.principio.mail-gmail - 9/29/2011 1:04:33 AM
   
RE:how to custom format datetime using eval.
Hi,

as the subjects says, how can I custom format (MMMM dd, yyyy) the datetime in blogpost using eval in cms_transformation.

I used <%# Eval("BlogPostDate", "BlogPostDate", "{0:dd MMMM yyyy}") %> but no luck.

I also used <%# Convert.ToDateTime(Eval("BlogPostDate")).ToString("MMMM dd, yyyy") %> but still no luck.

I used <%# Convert.ToDateTime(Eval("BlogPostDate")).ToString("d") %> and it worked! but not my preferred format. :(

Thanks,

JP

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 9/30/2011 4:30:40 AM
   
RE:how to custom format datetime using eval.
Hello,

You can use the following function and format your date as per your needs:

<%# GetDateTime("BlogPostDate", "MMMM dd, yyyy") %>

Best regards
Ondrej Vasil