homiebrah Posted June 21, 2004 Share Posted June 21, 2004 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. Link to comment Share on other sites More sharing options...
DarkPhoenix Posted June 21, 2004 Share Posted June 21, 2004 Which language? Javascript? VBScript? PHP? Perl? VB.NET? I can't really suggest anything until I know. Link to comment Share on other sites More sharing options...
XtremeMaC Posted June 21, 2004 Share Posted June 21, 2004 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 Link to comment Share on other sites More sharing options...
homiebrah Posted June 21, 2004 Author Share Posted June 21, 2004 Which language? Javascript? VBScript? PHP? Perl? VB.NET? I can't really suggest anything until I know.Javascript. Link to comment Share on other sites More sharing options...
DarkPhoenix Posted June 21, 2004 Share Posted June 21, 2004 Here, take a look at this.. you could probably borrow some of their code or something. Julian Date Converter Link to comment Share on other sites More sharing options...
homiebrah Posted June 21, 2004 Author Share Posted June 21, 2004 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. Link to comment Share on other sites More sharing options...
DarkPhoenix Posted June 21, 2004 Share Posted June 21, 2004 So not really the Julian calendar, but more like "Count of days since January 1"? Link to comment Share on other sites More sharing options...
DarkPhoenix Posted June 21, 2004 Share Posted June 21, 2004 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. Link to comment Share on other sites More sharing options...
homiebrah Posted June 22, 2004 Author Share Posted June 22, 2004 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. Link to comment Share on other sites More sharing options...
DarkPhoenix Posted June 22, 2004 Share Posted June 22, 2004 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? Link to comment Share on other sites More sharing options...
homiebrah Posted June 22, 2004 Author Share Posted June 22, 2004 If I knew javascript, I could. That's why I asked. Link to comment Share on other sites More sharing options...
MadGutts Posted June 23, 2004 Share Posted June 23, 2004 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now