SendGrid - formatDate with Insert tag definition - Error - sendgrid

I am trying to format the date using formatDate. None of the options is working in terms of formatting the date. Please suggest. We are using the insert tag to fetch values from the template.
{{insert notes_lead_creation_date}}
This date has to be formatted to DD/MM/YYYY. Currently the date has : notes_lead_creation_date:2058-07-25
Also, getting an error message.
This message has been dropped.

As per the documentation, you cannot format a date within an insert helper. If you are using insert to provide a fallback, you should use a conditional, like so:
{{#if notes_lead_creation_date}}
{{ formatDate notes_lead_creation_date "DD/MM/YYYY"}}
{{else}}
default content
{{/if}}
Note that the date must be provided in ISO8601 format too.

Related

Automatically set date in the front matter of a Jekyll page

When I create a post, in the front matter I have to insert layout, title, date etc. My concern is regarding date front matter. It is very inconvenient to insert date time and time offset in date field manually.
I'm not able to figure out how to do this automatically. I want the front matter date to update automatically with system time.
The date variable in front matter is an optional variable that you can set to be able to override the date that you set when you title your post according what Jekyll is looking for (i.e. 2019-12-14-post-title.md). It should only refer to the date the post was originally made, and not the current system date. Except for certain edge cases, you really shouldn't have to define date in the front matter.
You can use Liquid templating to post the current time to a page by passing the "now" keyword to date in your liquid template as follows:
This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}.
to get the the output:
This page was last updated at 2019-12-14 17:48.
However this method has a big drawback for Jekyll usage, because it will refer to the current date when the page was last generated from the template and not when the page is being visited by the user.
The best way to access the current system time is likely to use javascript instead. This is fairly easy depending on your familiarity with the language, but essentially you can make a Date object and then output the info you are looking to display. Here is a quick snippet I made that shows a couple methods that act on the Date object to output different values such as the date, time, and year:
<!DOCTYPE html>
<html>
<body>
<h3>The toDateString() method converts a date to a date string:</h3>
<p id="demo1"></p>
<h3>The toLocaleTimeString() method outputs formatted time:</h3>
<p id="demo2"></p>
<h3>The getFullYear() method outputs the year:</h3>
<p id="demo3"></p>
<script>
// create date object
var d = new Date();
// use toDateString() to output formatted date
document.getElementById("demo1").innerHTML = d.toDateString();
// use toLocaleTimeString() to output formatted time
document.getElementById("demo2").innerHTML = d.toLocaleTimeString();
// use getFullYear() to output year
document.getElementById("demo3").innerHTML = d.getFullYear();
</script>
</body>
</html>
W3schools has a good rundown of the Date object and how to format output if you need more examples and reference on usage.
If you need to know how to use Javascript with Jekyll there is a helpful post on Jekyll Talk that will help.
First of all, you do not HAVE to insert 'layout, title, date etc'. You can use Front Matter defaults for them. This only makes sense for the layout as the title can or should be default, nor the date.
The date MUST be set in your filename and can be overridden in the Front Matter. Please note that this is ONLY true for the built-in collection posts. If you use a custom collection you do not need a date at all.
However, if you choose to use posts nevertheless and you want to add the date automatically, there is only one real option: Use a CMS that automates this input, like Forestry.io or CloudCannon.

Need to format date in "MM-dd-yyyy" in netsuite template

I need to format the in template of netSuite without changing the global date format.
As if I am able to change the date format in template then it will work for all the users.
Here is the reference for Freemarker's Date built-ins: https://freemarker.apache.org/docs/ref_builtins_date.html
In particular you'll want to look at the string() function, which let's you pass in a Date format.

Grails: error executing tag <g:formatDate>: unknown class: java.lang.String with root cause

I have dates stored in my database in a format like this: 2017-04-12T00:00:00
I am displaying these on an index show page like so:
<td>${event.eventTime}</td>
I want to convert the date into a a regular format, I came across the grails formatDate tag.
I've tried variations of this but the error from the title still remains, where am I going wrong?
<td><g:formatDate date="${event.eventTime }" format="yyyy-MM-dd" /></td>
It appears that eventTime on your event object is a string rather than a date.
If you try the following as a test it should work:
<td><g:formatDate date="${new Date()}" format="yyyy-MM-dd" /></td>
Is eventTime stored as a date in the DB or maybe it's being converted en-route to the gsp?
To just strip off the time & keep the same format you could:
${event.eventTime?.substring(0, 10)}
Or you could convert to a date and back to another format:
<g:formatDate date="${Date.parse( "YYYY-MM-dd'T'hh:mm:ss", event.getTime )}" format="yyyy-MM-dd"/>

struts 2 s:date tag with value from variable in request with it's name in request

I have a problem in my web app with struts 2 and a date value. I've got a form and inside it an s:textfield that shows a date value. I read this value from request, and the problem is that the name of that value is in other variable.
The Action I'm calling does this:
...
public String execute(){ return SUCCESS;}
public MyObject getObject1(){
MyObject result = new MyObject();
result.setDate(new java.util.Date());
return result;
}
...
On SUCCESS it goes to my form.
The code in my form (what I was wondering to write) is:
<s:form action="save">
<s:set name="objName" value="object1"></s:set>
<jsp:include page="../includedform.jsp"></jsp:include>
</s:form>
And in the "includedform.jsp" there is:
<s:textfield name="%{objName}.date" label="Date" >
<s:param name="value">
<s:date name="%{%{objName}.date}" format="dd/MM/yyyy" />
</s:param>
</s:textfield>
The syntax:
%{%{objName}.anagrafica.dataNascita}
doesn't work (it shows nothing, obviously). So i'll need something like this but working :)
Other tags s:textfield inside "includedform.jsp" (ommited in the code bellow for simplicity) without date fields are working, because I am using only the name attribute and struts looks automatically for the value. This is the code I use for these textfields:
<s:textfield name="%{objName}.name" label="Name"/>
your question is very confusing and you need to rephrase to make it more clear and readable.
i am not sure why you are doing this
<s:textfield name="%{objName}.date" label="Date" >
while this can be done like
<s:textfield name="objName.date" label="Date" > OR
<s:textfield name="%{objName.date}" label="Date" >
when you write objName.date OGNL assume that you have a bean in your action class namely objName and this bean has property namely date, s ultimately this will get converted to
getObjName().getDate() by ONGL
On a similar fashion <s:date name="%{%{objName}.date}" format="dd/MM/yyyy" /> datee tag works
For more details please refer to the official doc
Struts2 Date tag
There is one solution which i tried and it worked :)
1)Keep the column in which you want to store date in database's table in "DATE" data type only.
2)Use only Textfield tag in JSP page.Dont use Date tag.
Note:Make sure that you make user input date in YYYY-MM-DD format only by placing a placeholder in textfield tag !
3)Keep the variable for accessing that field of string type only.Dont use DATE data type.
4)Now run Query: Select DATE_FORMAT(datecolumnname,'%d/%m%/Y') as date_two from tablename; and you will get date from that columnin dd/mm/yyyy format even if it is stored in YYYY-MM-DD format in table .
5)And you can also compare your datecolumn's data with curdate() and related functions as well and it works :) .
6)Like i used query: Select id,name,DATE_FORMAT(datecolumnname,'%d/%m/%Y') as datecolumn2 from tablename where datecolumnname >= curdate();

jquery datepicker date format with output of Zend_Locale

I'm trying to set the format for a jquery datepicker element with the date format returned by Zend_Locale::getTranslationList('date', $locale);
My problem is zend returns the string 'dd/MM/yyyy' for the date format but jquery expects only 2 characters for the year ie 'dd/mm/yy', so it enters the year twice 20112011
Is there some option that can be passed to either zend or jquery to make them work in the same manner? I've read through the docs and can't seem to find anything
Many thanks for your help in advance!
I have used jquery date picker in python-django framework when I give date format as dd/mm/yyyy format it returns 20112011 then i have corrected it to dd/mm/yy and it returned 2011 only. you can specify in your datepicker css class to specify the date format as dd/mm/yy.
Iam not sure if this is what you're looking for but:
// use german local, change it to our needs :-)
$locale = new Zend_Locale('de_DE');
$result = Zend_Locale::getTranslationList('date', $locale);
// returns dd.MM.yy (german!)
echo $result['short'];