Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26254 > unrolled thread

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

Started byJRough <janis.rough@gmail.com>
First post2014-11-29 13:57 -0800
Last post2014-11-30 17:45 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  need to evaluate and store a mustache variable for a date function JRough <janis.rough@gmail.com> - 2014-11-29 13:57 -0800
    Re: need to evaluate and store a mustache variable for a date function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-30 17:45 +0100

#26254 — need to evaluate and store a mustache variable for a date function

FromJRough <janis.rough@gmail.com>
Date2014-11-29 13:57 -0800
Subjectneed to evaluate and store a mustache variable for a date function
Message-ID<b9ca691a-354d-4eb0-b38c-c697707e99c7@googlegroups.com>
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>

[toc] | [next] | [standalone]


#26256

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-11-30 17:45 +0100
Message-ID<2856755.Lea29hFERk@PointedEars.de>
In reply to#26254
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.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web