How do I manipulate dates?

Mehr
4 Jahre 9 Monate her #94433 von AbbyW
AbbyW erstellte das Thema How do I manipulate dates?
I'm new to limesurvey and would like to get age on a certain date (01.01.2012) from the date of birth that is entered as the answer to a question. I figured I could just get the year from the date of birth with javascript (which I'm also new to). I tried to read it as a date and also as string, and am getting weird results. Any ideas what I'm doing wrong?

My code:

<script type="text/javascript" charset="utf-8">
document.write( "DOB = {INSERTANS:36485X1569X9272}<BR>");
var date1 = "{INSERTANS:36485X1569X9272}";
document.write("DOB1 : " + date1 + "<BR>");

var year1 = date1.substring(2);
document.write("Year : " + year1 + "<BR>");

var date2 = new Date("{INSERTANS:36485X1569X9272}");
document.write("DOB2 : " + date2 + "<BR>");
</script>



Output:
DOB = 12.01.2012
DOB1 : 12.01.2012
Year : pan id='LEMtailor_Q_9295_94'>
DOB2 : Invalid Date


Thanks so much!
Abby

Bitte Anmelden um an der Konversation teilzunehmen.

Mehr
4 Jahre 9 Monate her #94434 von Ben_V
Ben_V antwortete auf das Thema: How do I manipulate dates?

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)

Bitte Anmelden um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha