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

Forums / Developing with Sitefinity / Formatiing the Blog date

Formatiing the Blog date

39 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    26 Oct 2007
    Link to this post

    Hi,

    I am trying to figure out two things regarding the blog date:

    Firstly, how do you control the format of the blog date as it is just applied to a label in the post list like this: <asp:Label id="Publication_Date" runat="server"></asp:Label>

    There does seem to be a way to control the output format like with the news controls. I need to output the format "Thu, 26 July 2007 11:02:04 +1000" cause I want to do some in page date manipulation with javascript based upon the users system time.

    Secondly, is there a way to change the publication date selector so the user can select the time?

    Thanks

    Seth

  2. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    26 Oct 2007
    Link to this post
    Hi,

    I have figured out how to display the date.

    I am still keen to know if there a way to change the publication date selector so the user can select the time?

    Cheers,

    Seth
  3. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    29 Oct 2007
    Link to this post
    Hi Seth,

    It is easy enough you just need to edit the /Sitefinity/Admin/ControlTemplates/Blogs/ControlPanelInsert.ascx and ControlPanelEdit.ascx and change this:

             <radC:RadDatePicker ID="Publication_Date" runat="server"
                                </radC:RadDatePicker> 


    to:

      <radC:RadDateTimePicker ID="Publication_Date" runat="server"
                                </radC:RadDateTimePicker> 

    The one problem though is there is no Sitefinity theme skin for the DateTimepicker, yet.

    Hope that helps.

    Sean
  4. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    29 Oct 2007
    Link to this post
    Hi,

    Thanks Sean for that. That worked great. The default skin seems to work fine.

    Cheers,

    Seth
  5. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    29 Oct 2007
    Link to this post
    Hi,

    Implemented the RadDateTimePicker as suggested by Sean - which was the functionality I was after however it doesn't matter whether i pick am or pm from the time pcker it always saves as am. eg picking 4pm saves as 4 am.

    Any ideas for me?

    Thanks

    Seth
  6. Yasen
    Yasen avatar
    121 posts
    Registered:
    18 May 2013
    30 Oct 2007
    Link to this post
    Hello Seth Cleaver,

    I tested the blog posts with the DateTimePicker and it works fine. However, I think you are mislead by the time format that is displayed.

    For instance, I created a post with publication date: 29 Oct 2007, 07:00 PM , it is displayed in the posts grid as 29 Oct 2007, 07:00. But if you go back to edit the post you'll see that it is still 07:00 PM. So the problem is only in the format.

    To customize the format, you can use the Telerik.Cms.Web.UI.DateTimeLiteral control instead of the Literal control with ID="Publication_date" in the needed templates.

    If you need a specific place where to change the date format, feel free to ask again and we’ll do our best to help.


    All the best,

    Yasen
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  7. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    08 Nov 2007
    Link to this post
    Hi,

    The DateTimePicker definetly doesn't work right. You are correct if you go back in it says 7 pm but the output to the published page always output as am no matter whether you set pm or am.

    Thanks

    Seth
  8. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    08 Nov 2007
    Link to this post
    Hi Seth,

    Actually, we found a bug in the PostList and SinglePost controls which do not allow you to show any hour different than 12:00 am. Is your issue connected to this bug or there is something else? Would you let us know how to you format your date and where? Sending a working example would be best or at least give us some steps to reproduce this behavior.

    Thanks in advance.

    Greetings,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    13 Nov 2007
    Link to this post
    Hi,

    It seems it was my mistake. I am now having no problems getting the date and correct time output to the page.

    Seth
  10. Zumrut CIM
    Zumrut CIM avatar
    1 posts
    Registered:
    25 Jun 2007
    14 Feb 2008
    Link to this post
    Could you share the changing of the date format of the publication dates of blogs with me? Or maybe even give me some pointers on how to localize this date. I only get dates in my default culture, so either I fix the language or change the date format into something neutral. Little push would be much appreciated! Thanks. -- Jac
  11. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Feb 2008
    Link to this post
    Hello Zumrut CIM,

    Yes, it is possible to change the date format in Blogs section. Let's say you want to change your date format to dd-MM-yyyy or 14-02-2008.

    Browse to Sitefinity\ControlTemplates\Blogs, open PostListTemplate.ascx and add the following line to the begining of the file :

    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfCtrl" %> 

    Then, find
    <h3 class="postDate"
    <asp:Literal ID="Publication_date" runat="server"></asp:Literal> 
    </h3> 
    and change it to :
    <h3 class="postDate"
    <sfCtrl:DateTimeLiteral runat="server" ID="Publication_date" DateFormatString="dd-MM-yyyy"></sfCtrl:DateTimeLiteral> 
    </h3> 

    Find :
    <h2 class="postDate"
    <asp:Literal ID="Publication_date" runat="server"></asp:Literal>
    </h2>  


    and change it to :
    <h2 class="postDate"
                 <sfCtrl:DateTimeLiteral runat="server" ID="Publication_date" DateFormatString="dd-MM-yyyy"></sfCtrl:DateTimeLiteral> 
            </h2> 

    The blog posts list template is ready!

    Now, open SinglePostTemplate.ascx, and like in PostListTemplate.ascx, add this line to the begining of the file :
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfCtrl" %>  

    Find :
    <h2 class="postDate"
       <asp:Literal ID="Publication_date" runat="server"></asp:Literal>  
    </h2> 

    And change it to :
    <h2 class="postDate"
       <sfCtrl:DateTimeLiteral runat="server" ID="Publication_date" DateFormatString="dd-MM-yyyy"></sfCtrl:DateTimeLiteral> 
    </h2> 

    Now, you have to change the dates in the comments. Open CommentsList.ascx and find :

    <span class="commentDate"><%# DataBinder.Eval(Container.DataItem, "DateCreated", "{0:D}") %></span

    Change the text with green background to dd-MM-yyyy

    That's all! You may find more date formatting examples at Custom Date Time Format Strings
    As to localization, this technique will be enough to format your dates to neutral formats. For now, localization for dates of blogs and posts is not supported, but we have logged this request and will definitely consider it.

    I hope you find this helpful. Let us know if you need any further assistance.


    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  12. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    15 Feb 2008
    Link to this post
    Hi,

    Addtionally, if you want to have the time displayed as well you need to change the admin edit and insert templates to be able to set the time to by changing the RadDatePicker in the following files to RadDateTimePicker

    \Sitefinity\Admin\ControlTemplates\Blogs\ControlPanelEdit.ascx
    \Sitefinity\Admin\ControlTemplates\Blogs\ControlPanelInsert.ascx

    Thanks

    Seth
  13. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    15 Feb 2008
    Link to this post
    Hello Seth Cleaver,

    That's right. Thank you for the elucidation. Your Telerik points have been updated for helping out.

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  14. Adam
    Adam avatar
    63 posts
    Registered:
    30 Jan 2008
    23 May 2008
    Link to this post
    I wanted to Add one more note to this thread.  Something that I have found useful when trying to manipulate the date is to grab the data using the DataBinder.Eval method found in the NewsList.ascx control.  I like this method because it allows me to enter more than one Date value on the same page instead of being limited by having only one control on the page with the ID of Publication_Date.  Here's the code:

    <%#DataBinder.Eval(Container.DataItem, "Publication_Date", "{0:dd}")%> 
  15. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    09 Mar 2009
    Link to this post

    <%#DataBinder.Eval(Container.DataItem, "Publication_Date", "{0:dd}")%>  

    I've tried the above, it works on this page if i comment out the existing literal
    \ControlTemplates\News\Modes\ListPageMaster.ascx

    however, if i try the same on this control
    \ControlTemplates\News\Modes\ListPageDetails.ascx

    it errors

    any ideas?
  16. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    09 Mar 2009
    Link to this post

    <%#DataBinder.Eval(Container.DataItem, "Publication_Date", "{0:dd}")%>  

    I've tried the above, it works on this page if i comment out the existing literal
    \ControlTemplates\News\Modes\ListPageMaster.ascx

    however, if i try the same on this control
    \ControlTemplates\News\Modes\ListPageDetails.ascx

    it errors

    any ideas?
  17. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    09 Mar 2009
    Link to this post

    <%#DataBinder.Eval(Container.DataItem, "Publication_Date", "{0:dd}")%>  

    I've tried the above, it works on this page if i comment out the existing literal
    \ControlTemplates\News\Modes\ListPageMaster.ascx

    however, if i try the same on this control
    \ControlTemplates\News\Modes\ListPageDetails.ascx

    it errors

    any ideas?
  18. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    10 Mar 2009
    Link to this post
    Hello Adam,

    DataBinder.Eval method is used when binding data to data-bound list controls (GridView, DetailsView, DataList, Repeater). That is the reason why your approach works only for the ListPageMaster.ascx template. To set formatting in the detail template, you could use Telerik.Cms.Web.UI.DateTimeLiteral control:

    <telerik:DateTimeLiteral ID="Publication_Date" runat="server" DateFormatString="dd MMM yyyy"></telerik:DateTimeLiteral> 

    Hope you will find the provided information useful.

    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  19. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    11 Mar 2009
    Link to this post
    thanks

    I tried on the ListPageDetails.ascx but get the following error

    Error 111 Unknown server tag 'telerik:DateTimeLiteral'
    ....\News\Modes\ListPageDetails.ascx 12 
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Mar 2009
    Link to this post
    Hello Quade,

    Give a try to the line below:

    <sfWeb:DateTimeLiteral ID="lastPostDate" runat="server" DateFormatString="dd MMM yyyy"></sfWeb:DateTimeLiteral> 

    The tag prefix for Telerik.Cms.Web.UI is different for the template you are referring. If you want you can register additional tag prefix( let's say "telerik" for Assemblie="Telerik.Cms.Web.UI")

    Example:

    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="telerikControls" %> 
     

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  21. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Mar 2009
    Link to this post
    Thanks

    I've tried what you posted, but i get the error:

    Parser Error Message: Unknown server tag 'sfWeb:DateTimeLiteral'.
    <sfWeb:DateTimeLiteral ID="lastPostDate" runat="server" DateFormatString="dd MMM yyyy"></sfWeb:DateTimeLiteral> 

    Just to clarify, i'm trying this on the news details page
    Can i not use the existing tag???

    <asp:Literal ID="Publication_Date" runat="server" Text="{0}" />
    and use the text attribute to format the date?
    Thanks

     

  22. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    13 Mar 2009
    Link to this post
    Hi Quade,

    Did you add the Register tag to the top of the ascx file as Ivan so kindly pointed out in his last post.

    As he already explained that because the "Details" control isn't a databound control then no you can't use the standard ASP.net literal.

    With the Generic Content pages details pages it will set the Text properly automatically when the page loads, but their clever little literal will do the formatting for you.

    Cheers
    Sean
  23. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Mar 2009
    Link to this post

    Sean
    Thanks, yes i did use the Register Tag exactly how it was pasted in

    Am i missing something obvious?

  24. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    13 Mar 2009
    Link to this post
    Quade,

    I see the problem, in fact Ivan's code has a teeny mistake in it....

    The register should be:

    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %> 

    The TagPrefix should be matching the bit before the colon of the controls declaration <sfWeb

    HTH

    Sean
  25. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Mar 2009
    Link to this post
    Its working
    Thanks

    you deserve some points for that!
  26. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Mar 2009
    Link to this post
    Its working
    Thanks

    you deserve some points for that!
  27. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Mar 2009
    Link to this post
    appologies for the dupe post, the site timed out when posting, so i tried again
  28. Magnus
    Magnus avatar
    28 posts
    Registered:
    26 May 2009
    14 Dec 2009
    Link to this post
    I will return this thread to life by asking how to get the Publication_date from a blogpost to be formatted as "20/12/2009".

    <telerik:DateTimeLiteral runat="server" ID="Publication_Date" DateFormatString="dd/MM/yyyy"></telerik:DateTimeLiteral> 

    isnt working so good.

    any other suggestions?  (using SF  3.7 SP2.)
  29. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    14 Dec 2009
    Link to this post
    Hi Magnus,

    By design BlogPost has a TextSettingsProperty - Date from where you can set the Date format. Please open the BlogPosts control and edit to BlogSettings section. If you want to add additional date formats you should do the following.

    1. Map the external tempalte - TextSettingsTemplate. More information about the mapping at How to map a template

    2. Modify the template as shown below:

    <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 Text="CustomFormat" Value="dd/mm/yyyy"></asp:ListItem>
             </asp:DropDownList>
             <p class="example">Example</p>
         </asp:Panel>


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  30. Magnus
    Magnus avatar
    28 posts
    Registered:
    26 May 2009
    14 Dec 2009
    Link to this post
    "TextSettingsProperty - Date" - That i'm aware of. But the format "dd/mm/yyyy" isn't a valid DateTime-string. (getting error). So i need to try the other solution.


    1. I've mapped the template and changed the code to yours.. But how does that change the format in the itemlist? (cause i'm editing in the admin section). Do i need to change the format in ContentViewItemList.ascx? Or should that be changed automatically?  I've tried with some formats and even without the "DateFormatString" option.




Register for webinar
39 posts, 0 answered
1 2