Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > currentdate - can it be formatted View modes: 
User avatar
Member
Member
zelewsky-lbpc - 7/20/2010 11:32:35 AM
   
currentdate - can it be formatted
I want to be able to format the date that I'm adding via a macro, but everything I've tried won't work. All I can get it the numeric date with slashes -- MM/DD/YYYY -- by using
{%currentdate%}

Is it possible to use a macro like currentdate.tostring("DD MM, YYYY")?

What would the correct syntax be?

Thanks,
Paul

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/21/2010 2:26:40 AM
   
RE:currentdate - can it be formatted
Hi,

to achieve your need you need to create a custom macro, which will format the date/time according to your needs. There is no default macro for this at the moment.

Best regards,
Juraj Ondrus

User avatar
Member
Member
Aon_Vlado - 1/29/2013 10:01:16 AM
   
RE:currentdate - can it be formatted
It is a new year and I realized would be nice to have a macro {%CurrentYear%} to be able to use it in Copyright note. Maybe in next Kentico version....

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/30/2013 1:39:02 AM
   
RE:currentdate - can it be formatted
Hi,

This is pretty old thread. since then the macros very vastly improved and K# was introduced.

You can take a look to the K# syntax documentation and there is example how to work with dates and you can take inspiration from it to create the macro (Open condition and loops frame):
"{% date = CurrentDateTime; if (date.Year > 2011) { ResolveMacros("\r\nThe current date is: {%date%\}. The registration period has ended.\r\n") } %}
Best regards,
Juraj Ondrus

User avatar
Member
Member
Aon_Vlado - 1/30/2013 7:53:12 AM
   
RE:currentdate - can it be formatted
Thank you, this is what I was looking for.