[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

need to evaluate and store a mustache variable for a date function

jrough

11/29/2014 9:58:00 PM

I need the date in another format than JSP and since I don't know Java I would like it to be in javascript. I don't know how to store the Mustache variable so I can input it into the date function? I need the filingDate value from mustache as input into the date object. thanks,


<li class="activity-list {{type}}"><div id="activity-date"> <script>
var d = new Date( {{filingDate}} );document.write(d.getMonth(d))</script></div></li>
1 Answer

Thomas 'PointedEars' Lahn

11/30/2014 4:46:00 PM

0

JRough wrote:

> I need the date in another format than JSP and since I don't know Java I
> would like it to be in javascript. I don't know how to store the Mustache
> variable so I can input it into the date function? I need the filingDate
> value from mustache as input into the date object. thanks,
>
>
> <li class="activity-list {{type}}"><div id="activity-date"> <script>
> var d = new Date( {{filingDate}}
> );document.write(d.getMonth(d))</script></div></li>

If â??{{filingDate}}â? expands to a number specifying the number of seconds or
milliseconds since Epoch for that date, then you can use that approach
(seconds would have to be multiplied by 1'000); otherwise, as we have
determined recently [1], you SHOULD NOT.

If â??{{filingDate}}â? expands to a string from which you can extract the month
number, such as "2014-11-30", then you can assign, for example:

var d = "{{filingDate}}";

and then use string methods to process the value of â??dâ? (also discussed
recently).

However, it is likely that Mustache has a way to get to the information
without client-side scripting; it would be better that way, unless you can
make sure that client-side scripting and document.write() is supported with
the user. Still, document.write() should be avoided as it slows down
rendering of the document; tree-modifying methods introduced with the W3C
DOM should be used instead.

Mustache is off-topic here, though, as you have been told before. Please
read and follow the recommendations in the FAQ. And get a real name.

_______
[1] <news:0d947d29-c683-4417-b081-983f18bb11bf@googlegroups.com>
--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.