Day = NoImage. Night = YesImage. . . Possible?

  • willstein
  • Loser
  • Loser
  • willstein
  • Posts: 117
  • Loc: Maryland

Post 3+ Months Ago

Hey,

I need to find a way, to make certain code appear at night, and the code dissappear in the day.

In other words.
picture.jpg only appears on my website at night time.

any suggestions?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23460
  • Loc: Woodbridge VA

Post 3+ Months Ago

You'll need to use javascript time/date functions. This isn't precisely the code you would use, but this demonstrates how the function retrieves time and date from the viewer's internal clock.

Code: [ Select ]
<b>Todays Date: </b><SCRIPT LANGUAGE="JavaScript">
<!--
Stamp = new Date();
document.write('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + ' <br> ');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}

if (Hours > 12) {
Hours -= 12;
}

if (Hours == 0) {
Hours = 12;
}

Mins = Stamp.getMinutes();

if (Mins < 10) {
Mins = "0" + Mins;
}

document.write('<B>Todays Time:</b> ' + Hours + ":" + Mins + Time + '');

//-->
</SCRIPT>
  1. <b>Todays Date: </b><SCRIPT LANGUAGE="JavaScript">
  2. <!--
  3. Stamp = new Date();
  4. document.write('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + ' <br> ');
  5. var Hours;
  6. var Mins;
  7. var Time;
  8. Hours = Stamp.getHours();
  9. if (Hours >= 12) {
  10. Time = " P.M.";
  11. }
  12. else {
  13. Time = " A.M.";
  14. }
  15. if (Hours > 12) {
  16. Hours -= 12;
  17. }
  18. if (Hours == 0) {
  19. Hours = 12;
  20. }
  21. Mins = Stamp.getMinutes();
  22. if (Mins < 10) {
  23. Mins = "0" + Mins;
  24. }
  25. document.write('<B>Todays Time:</b> ' + Hours + ":" + Mins + Time + '');
  26. //-->
  27. </SCRIPT>


You would have to alter it, by adding functions to test for the start and stop times you want your image displayed. I'm sure this would work, but I have to step out for most of the day and don't have the time to sit down and write it all out. That should at least get you started in the right direction.
  • willstein
  • Loser
  • Loser
  • willstein
  • Posts: 117
  • Loc: Maryland

Post 3+ Months Ago

alright, that might work, but what if the image itself is javascript?


would I still be able to input it?
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

all that code does (i think) is spit out the date and time. Nothing more, nothing less. You would need to do some sever modification.

I personally woud do it using PHP, for several reasons, not the least of which is that it stops websmart visitors from using the View Source command and bypassing you protection. If you have access to PHP, i'll look into it for you.
  • willstein
  • Loser
  • Loser
  • willstein
  • Posts: 117
  • Loc: Maryland

Post 3+ Months Ago

thanks for the offer but i got it down.
yeah i used php.

check out -REMOVED- from 1-5 EST and yuu'll see a mess of banner ads.
catchya later.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

wasn't this post somewhere else?

yes I thought so this was just a cross post of http://www.ozzu.com/viewtopic.php?t=18873&start=0
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6375
  • Loc: twitter.com/unflux

Post 3+ Months Ago

:roll: tired of this

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 22 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.