Problems changing the date and time for blog entries

Posted by Community Admin on 04-Aug-2018 10:28

Problems changing the date and time for blog entries

All Replies

Posted by Community Admin on 18-Mar-2011 00:00

Hi there,


Im currently using the blog module to display a list of blog entries on my homepage. The problem is im trying to get the date format to the following: 10 Feb '09. Note that the apostrophe is vital.

This what I have done but isn't working:

I have mapped the textSettingsTemplate.ascx and edited the code as follows:

<asp:Panel ID="dateTimeFormatPanel" runat="server">
          <asp:Label ID="lbl3" runat="server" Text="Date format" AssociatedControlID="dateTimeFieldFormat"></asp:Label>
          <asp:DropDownList ID="dateTimeFieldFormat" runat="server">
          <asp:ListItem Value="dd MMM yy" Text="Petes Date and Time" />
          </asp:DropDownList>
          <p class="example"></p>
      </asp:Panel>

When I go to the blog settings and change the format to "Petes date and Time" the following occurs

09 Feb 2010 (What Im trying to achieve: 10 Feb '09)

How can I get the apostrophe? I've already gone to the microsoft page about the date formats but they don't really make any sense, particularly the part about adding the apostrophe.

Thanks for your time

Peter

Posted by Community Admin on 21-Mar-2011 00:00

Hi Peter,

Thank you for contacting Telerik Support.

Please see the attached sample code,. which can help you specify your own Format:

DateTime date = DateTime.Today;
Console.WriteLine(date.ToString("MMM \"'\"yy"));
//Any text between the two escaped quotation marks (\”…\”) will be printed as literal text

or you can direcly modify the BlogPosts widget template like this:
<sf:FieldListView ID="PostDate" runat="server" Format=" | PublicationDate.ToLocal():  dd MMM, '\''yy" />
 Both methods return the desired DateTime Format.

I hope this information helps. If you need any further assistance, please do not hesitate to contact me. Thanks in advance.

Best wishes,
Boyan Barnev
the Telerik team

Posted by Community Admin on 22-Mar-2011 00:00

Brilliant,

Boyan, I just want to thank you for giving me a decent and well thought out answer, sadly this doesn't happen too often. :) Really appreciate the effort.

Thanks again,

Peter

Posted by Community Admin on 22-Mar-2011 00:00

Hi Boyan,

I have followed all of the steps to map the control "TextSettingTemplate.ascx". Where do I make the code change for this:

DateTime date = DateTime.Today;
Console.WriteLine(date.ToString("MMM \"'\"yy"));
//Any text between the two escaped quotation marks (\”…\”) will be printed as literal text

In what file does this change need to be made because I cannot see this in the TextSettingTemplate.ascx or in the TextSettingTemplate.ascx.resx file.

Thanks,
James

Posted by Community Admin on 23-Mar-2011 00:00

Hi Boyan,

Any more info on this?

Thanks

Posted by Community Admin on 23-Mar-2011 00:00

Hello James,

You can set this date fromat  in any of the templates (Go to Sitefinity backend ->Design->Widget Templates) that contain fields of type DateTime to achieve the same functionality.
I believe Peter was talking about a custom template in the first post.

Greetings,
Boyan Barnev
the Telerik team

This thread is closed