PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jan 22, 2017 7:16 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Sep 26, 2016 10:08 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 3777
Location: United Kingdom
Syntax: [ Download ] [ Hide ]
//change the text below to reflect your own,
var before="Christmas Day!"
var current="It's Christmas Day!!"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
document.write(current)
else if (difference>0)
document.write("The Christmas Countdown Starts Here!  Only "+difference+" days to go...")
}
//enter the count down date using the format year/month/day
countdown(2015,12,25)

I've got this countdown script we used last year, and we want to use it again, but I don't recall how I made it appear on screen.

I have tried this:
Syntax: [ Download ] [ Hide ]
<script src="/js/xmas.js"></script>

But nothing shows,


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:12 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 5820
Location: Montreal, Canada
Did you try updating the date to 2016?

_________________
PHP 7.1.0 released
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:19 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 3777
Location: United Kingdom
Syntax: [ Download ] [ Hide ]
//change the text below to reflect your own,
var before="Christmas Day!"
var current="It's Christmas Day!!"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
document.write(current)
else if (difference>0)
document.write("The Christmas Countdown Starts Here!  Only "+difference+" days to go...")
}
//enter the count down date using the format year/month/day
countdown(2016,12,25)


Yes just tried this. I was assuming just adding the js code on the page would do it.


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:23 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 5820
Location: Montreal, Canada
So it's sorted?

_________________
PHP 7.1.0 released
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:24 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 3777
Location: United Kingdom
No. It's not producing anything on screen.
If you do a dummy page, with that code, in theory it should show... should it not?


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:24 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 5820
Location: Montreal, Canada
I did, and it does.

_________________
PHP 7.1.0 released
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Mon Sep 26, 2016 10:32 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 3777
Location: United Kingdom
How?? Exactly as I did. that's bizarre.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group