June 21, 200422 yr I'm trying to find a script that will convert the current date to the three digit number for the year, i.e. Jan 5 would be 005, etc.
June 21, 200422 yr Which language? Javascript? VBScript? PHP? Perl? VB.NET? I can't really suggest anything until I know.
June 21, 200422 yr I don't have the code but u can use get time and then define numbers for the monthif month == 'january'( month = '0' )if day == '5' (day == '05')u might need to put them as vars something like that
June 21, 200422 yr Author Which language? Javascript? VBScript? PHP? Perl? VB.NET? I can't really suggest anything until I know.Javascript.
June 21, 200422 yr Here, take a look at this.. you could probably borrow some of their code or something. Julian Date Converter
June 21, 200422 yr Author This was the first one I looked at. I need the three digit number, not the number of days since a point in the past.
June 21, 200422 yr Aha! I think I discovered what you want... see this:<script>/*Count up from any date script-By JavaScript Kit (www.javascriptkit.com)Over 200+ free scripts here!*/var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")var today=new Date();function dayssincenewyear(){var m=01var d=01var todayy=today.getYear()if (todayy < 1000)todayy+=1900var yr=todayyvar todaym=today.getMonth()var todayd=today.getDate()var todaystring=montharray[todaym]+" "+todayd+", "+todayyvar paststring=montharray[m-1]+" "+d+", "+yrvar difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)//Modified by DarkPhoenix beneath line to function like intented//-----------------------------------------------------------------------difference = "" + difference;if (difference.length==1) {return "00" + difference;} else if (difference.length==2) {return "0" + difference;} else if (difference.length==3) {return difference;}}</script>Put that in the <head> part of your document, and then wherever you need the count, just get it, for instance like this:<script>alert(dayssincenewyear());</script>Works for me.
June 22, 200422 yr Author I think this is close. I went back to the site and modified the script slightly based on the original code from JavaScript. Now, if I can only get it to reflect the fact we are 9 hours behind GMT, so that when it hits 0000 there, it will increase the count to next number.
June 22, 200422 yr Oh.. you want it to follow GMT? That's rather hard to do, as JavaScript is a client-side script system, and will adjust to the user's local time... and since (at least that script) doesn't account for hours/minutes/seconds, it'll only change when the actual date changes... I could try to modify it to take account for hours/minutes/seconds also, if you wish.. or you could do it yourself, maybe?
June 23, 200422 yr Is this script being used on a local intranet? or on the web?If you use it on the web, then as DarkPhoenix said, the clock on the local machine is what the javacode will use.I dont know if this will work, But.... If you could ge the time from a UK time server instead of the local clock, then it would be far more acurate than the local clock.Windows 2000 server needs to sync to a time server regularly. But i used to have a program for Windows 98 and 2k to connect and correct the local time.Hope this is of some help.
Create an account or sign in to comment