Welcome, Guest
Username: Password: Remember me

TOPIC: How do I manipulate dates?

How do I manipulate dates? 1 year 3 months ago #94433

  • AbbyW
  • AbbyW's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 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
The administrator has disabled public write access.

How do I manipulate dates? 1 year 3 months ago #94434

  • Ben_V
  • Ben_V's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 1061
  • Thank you received: 234
  • Karma: 74
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...
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.114 seconds
Donation Image