+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Problems changing the date and time for blog entries

Problems changing the date and time for blog entries

6 posts, 1 answered
  1. Peter
    Peter avatar
    30 posts
    Registered:
    08 Dec 2010
    18 Mar 2011
    Link to this post
    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
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    02 Dec 2016
    21 Mar 2011
    Link to this post
    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
    Answered
  3. Peter
    Peter avatar
    30 posts
    Registered:
    08 Dec 2010
    22 Mar 2011
    Link to this post
    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
  4. James@Nw
    James@Nw avatar
    265 posts
    Registered:
    05 May 2009
    22 Mar 2011
    Link to this post
    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
  5. James@Nw
    James@Nw avatar
    265 posts
    Registered:
    05 May 2009
    23 Mar 2011
    Link to this post
    Hi Boyan,

    Any more info on this?

    Thanks
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    02 Dec 2016
    23 Mar 2011
    Link to this post
    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
6 posts, 1 answered