Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: How do I manipulate dates?

How do I manipulate dates? 1 Jahr 7 Monate her #94433

  • AbbyW
  • AbbyWs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 1
  • Karma: 0
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

How do I manipulate dates? 1 Jahr 7 Monate her #94434

  • Ben_V
  • Ben_Vs Avatar
  • OFFLINE
  • Platinum Lime
  • Beiträge: 1125
  • Dank erhalten: 259
  • Karma: 79
may this previous post help you
Benoît

goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche)
goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar)
goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de...
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.122 Sekunden
Donation Image