I want to change the format of date in comment published. The default format is like '3/29/2014 2:43:30 AM' and I want to change it (for example MMMM dd, yyyy HH:MM:SS AM).

I use this DWT code:

<p class="author"><tcdl:ContextVariable var="ugcComment.user.name"/></p>
<p class="date"><tcdl:ContextVariable var='ugcComment.LastModifiedDate'/></p>

Is there a method to change the format date?

2 Answers 2


To give format to the date fields in UGC we usually use the following code using javascript:

 <script type="text/javascript">
    var date = "<tcdl:ContextVariable var="ugcComment.creationDate"/>";
    var d = new Date(date.replace(/CES?T/,"    "));
    var curr_date = ('0' + d.getDate()).slice(-2);
    var curr_month = ('0' + (d.getMonth() + 1)).slice(-2);
    var curr_year = d.getFullYear();
    var curr_hh = d.getHours();
    var curr_mm = d.getMinutes();
    document.write("<p class=\"fecha\">" + curr_date + "-" + curr_month + "-" + curr_year + " " + curr_hh +":"+ curr_mm +"</p>");

If you prefer server-side solution, you could do as following (in .net):

<% DateTime commentCreateionDate = (DateTime) Tridion.ContentDelivery.UGC.Web.UI.When.EvaluateVariable("ugcComment.CreationDate", HttpContext.Current); %>    
// add your desired format
<% =commentCreateionDate.ToString("dd MM yyy") %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.