Get current date in widget template

Posted by Community Admin on 04-Aug-2018 20:54

Get current date in widget template

All Replies

Posted by Community Admin on 20-Apr-2016 00:00

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

Posted by Community Admin on 22-Apr-2016 00:00

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
 

Posted by Community Admin on 22-Apr-2016 00:00

It works. Thank you Dimitri.

This thread is closed