Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Date to Julian Day

Featured Replies

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.


Which language? Javascript? VBScript? PHP? Perl? VB.NET? I can't really suggest anything until I know.

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

  • Author
Which language? Javascript? VBScript? PHP? Perl? VB.NET? I can't really suggest anything until I know.

Javascript.

  • 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.

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. :)

  • 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.

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? :)

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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.