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

Forums / Developing with Sitefinity / Get current date in widget template

Get current date in widget template

3 posts, 0 answered
  1. Brew Hutch
    Brew Hutch avatar
    12 posts
    Registered:
    15 Apr 2010
    20 Apr
    Link to this post

    Hello,

    I'm modifying the event widget template, but I have no idea how to get the current date (DateTime.Now()) to be compared with the EventEnd field. Is there a way to accomplish this?

    <sf:Conditional If='<%# DateTime.Now() > (DateTime)Eval("EventEnd") %>' runat="server">
      <Then>
        Event ends.
      </Then>
      <Else>
        Event is active.
      </Else>
    </sf:Conditional>

    Please advise.

    Thanks,

    Brew

  2. Dimitri Cools
    Dimitri Cools avatar
    80 posts
    Registered:
    07 Dec 2016
    22 Apr
    Link to this post
    Hi,

    Can you please try to use the below sample which works for me:

    <sf:Conditional If='<%# DateTime.Now < (DateTime)Eval("EventEnd") %>' runat="server">
    <Then>
    <%# Eval("Title")%>'s end date (<%# Eval("EventEnd") %>) is AFTER than Now
                         
    </Then>
    <Else>
    <%# Eval("Title")%> 's end date (<%# Eval("EventEnd") %>) is BEFORE than Now
    </Else>
    </sf:Conditional>

    Please observe the screenshot for the result: http://screencast.com/t/kNLk6uC6PG86

    Regards,
    Dimitri Cools
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Brew Hutch
    Brew Hutch avatar
    12 posts
    Registered:
    15 Apr 2010
    22 Apr in reply to Dimitri Cools
    Link to this post
    It works. Thank you Dimitri.
3 posts, 0 answered