Conversion of Jualian Date entry to standard Date

Hopefully a simple answer for this one but I need it quickly so here goes.

I need a form that when a person plugs in a 3-digit Julian date representing the day of the year then hits submit and the standard date appears.  Such as someone types in 165 then hits submit (or if no button is required and something automatically does it would be cool) then a field below it states Jun 13, 2008

Any ideas?
austintreAsked:
Who is Participating?
 
ZvonkoConnect With a Mentor Systems architectCommented:
Check this:
<html>
<head>
<title>Zvonko &#42;</title>
<script>
function getDate(theField){
  var theForm = theField.form;
  var jDay = theField.value.replace(/\D/g,'');
  if(jDay!=theField.value) theField.value = jDay;
  theForm.date.value = "";
  if(jDay){
    var theDate = new Date();
    var YY = theDate.getFullYear();
    var theDate = new Date(YY,0,jDay);
    var MM = theDate.getMonth()+1;
    var DD = theDate.getDate();
    theForm.date.value = d2(DD)+"."+d2(MM)+"."+YY;
  }
}
function d2(theNum){
  if(theNum<10) return "0"+theNum;
  return theNum;
}
</script>
</head>
<body>
<form>
<input type="text" name="julian" size="3" maxlength="3" onKeyUp="getDate(this)" >
<input type="text" name="date" size="10" onFosus="this.blur()" >
</form>
</body>
</html>

Open in new window

0
 
ZvonkoSystems architectCommented:
So the Julian date corelates allways the the current Year, right?
0
 
austintreAuthor Commented:
Yes exactly
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
austintreAuthor Commented:
That works - but can I format it so that it shows Jun 13, 2008?  If not this is good enough!

Cheers
0
 
ZvonkoSystems architectCommented:
Open a new question for that :-)
0
 
austintreAuthor Commented:
That was part of the question to begin with.  

That is like me going to my doctor and asking for a diagnosis and he hands it to me in French and then tells me to come back again tomorrow so he can bill me again to get it in English.
0
 
ZvonkoSystems architectCommented:
So in English: Is it really for you a problem to convert the MM number to one of twelve Month names?
0
 
austintreAuthor Commented:
Yes it is considering I have no clue how to use JavaScript.  I don't do this for a living.  Just trying to help someone out.  But don't worry about it.  Sorry to have wasted your "genius" time.  

Thank you for the solution you gave it got me far enough.
0
 
ZvonkoSystems architectCommented:
For a ThankYou I do everything ;-)
<html>
<head>
<title>Zvonko &#42;</title>
<script>
function getDate(theField){
  var theForm = theField.form;
  var jDay = theField.value.replace(/\D/g,'');
  if(jDay!=theField.value) theField.value = jDay;
  theForm.date.value = "";
  if(jDay){
    var theDate = new Date();
    var YY = theDate.getFullYear();
    var theDate = new Date(YY,0,jDay);
    var MM = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(',')[theDate.getMonth()];
    var DD = theDate.getDate();
    theForm.date.value = MM+" "+d2(DD)+", "+YY;
  }
}
function d2(theNum){
  if(theNum<10) return "0"+theNum;
  return theNum;
}
</script>
</head>
<body>
<form>
<input type="text" name="julian" size="3" maxlength="3" onKeyUp="getDate(this)" >
<input type="text" name="date" size="10" onFocus="this.blur()" >
</form>
</body>
</html>

Open in new window

0
 
austintreAuthor Commented:
Thank you
0
 
ZvonkoSystems architectCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.