Jump to content

Date to Julian Day


Recommended Posts


I don't have the code but u can

use get time and then define numbers for the month

if 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

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=01
var d=01
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var yr=todayy
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var paststring=montharray[m-1]+" "+d+", "+yr
var 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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...