How can I format a Date in a HTML custom layout template?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2456
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

How can I format a Date in a HTML custom layout template?

Post by Jaymer »

<div class="aw-data-item">
<b>{Subject}</b> by {sc_CreatedBy} on {CreatedOn}
</div>

The date displays 27-09-2018
but that format isn't used in any of my Date attributes.

Isn't there a way to format this using an @ sign or something.
Like this... {CreatedOn,@MM/dd/yy}
Last edited by Jaymer on Sun Sep 30, 2018 6:45 pm, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: How to format a Date in a HTML custom layout template

Post by PointsWell »

Jaymer wrote:<div class="aw-data-item">
<b>{Subject}</b> by {sc_CreatedBy} on {CreatedOn}
</div>

The date displays 27-09-2018
but that format isn't used in any of my Date attributes.

Isn't there a way to format this using an @ sign or something.
Like this... {CreatedOn,@MM/dd/yy}
When you are using HTML on forms it is <<BO.CreatedOn, MM/dd/yy>> no @ sign (though I prefer the Dutch name for it: "monkey tail")
Jaymer
Posts: 2456
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to format a Date in a HTML custom layout template

Post by Jaymer »

still need a solution.
this is in a custom layout template where << >> are NOT used
thx
jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: How to format a Date in a HTML custom layout template

Post by BLOMASKY »

why not just create a new computed field (text) that has a rule to format the date the way you want it displayed and use that field on the form.

Bruce
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: How to format a Date in a HTML custom layout template

Post by tford »

Silly question, Jaymer, but did you put M/dd/yy in the Format section of the Date attribute you are trying to display in the query?
Tom - V8.8 build 3137 - MySql / PostGres
Jaymer
Posts: 2456
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to format a Date in a HTML custom layout template

Post by Jaymer »

Good questions and suggestions guys, but you're missing the boat.

See the pics below and you'll see where this is used.
Thanks!

Definition of the Field:
Screen Shot 2018-09-29 at 9.04.37 PM.png
Screen Shot 2018-09-29 at 9.04.37 PM.png (26.36 KiB) Viewed 11141 times
Its for a Combo Box on a form, to pretty the dropdown options:
Screen Shot 2018-09-29 at 9.03.02 PM.png
Screen Shot 2018-09-29 at 9.03.02 PM.png (54.09 KiB) Viewed 11141 times
Result looks like this:
Screen Shot 2018-09-29 at 9.01.45 PM.png
Screen Shot 2018-09-29 at 9.01.45 PM.png (59.84 KiB) Viewed 11141 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2456
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to format a Date in a HTML custom layout template

Post by Jaymer »

This is from a Custom Query, and it CORRECTLY used a Format associated with the Attribute to format the Date.
Must be a bug in the Custom List code.

THIS: Event Date: <b>{TransDate, @MM/dd/yy}</b></br> did not work. Output was the same.
THIS: Event Date: <b>{TransDate,@MM/dd/yy}</b></br> threw an error for unknown field when trying to Save template.

But the Question is still valid:
In this Custom Query, how would you format the Timestamp field to ONLY show the Date and NOT the time?

Custom Query snippet:

Code: Select all

<div class="aw-data-item">
Event Date: <b>{TransDate}</b></br>
Type: <b>{TransType}</b></br>
Descr:: <b>{Descr}</b></br>
Message: <b></b></br>
Opened: <b>{xOpened}</b> Clicked: <b>{xClicked}</b> Bounced: <b>{xBounce}</b></br>
</div>
Screen Shot 2018-09-29 at 11.11.59 PM.png
Screen Shot 2018-09-29 at 11.11.59 PM.png (17.48 KiB) Viewed 11137 times
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How can I format a Date in a HTML custom layout template

Post by aware_support »

This is what you can do:

# var d = kendo.parseDate (data["NameOfYourDateOrTimestampAttribute"], "MM/dd/yyyy HH:mm"); #
# var s = kendo.toString (d, "MMM dd yyyy"); #
<span>
#= s #
</span>
Aware IM Support Team
Jaymer
Posts: 2456
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How can I format a Date in a HTML custom layout template

Post by Jaymer »

thanks - this is a great help
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply