Archived

This topic is now archived and is closed to further replies.

PHP date question.

This topic is 5035 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Well I was trying to get a website with the time on it. Not updating or anything but like the time it is when you load the page. So i used this:
<script language = "javascript">
time = new Date();
if(time.getMinutes() < 10){
minutes = 0 + time.getMinutes();
}
else{
minutes = time.getMinutes();
}
hours = ((time.getHours()/2) - (time.getHours()%2));
document.write(hours + ":" + minutes);
</script>

For some reason it still puts the hours as .5 if the hour is an odd number. Doesn''t make sense to me.
Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don''t need you!|Sloth: Hey you guys!|

Share on other sites
This doesn''t answer your question but please don''t put PHP in the topic if it has to deal with JavaScript.

VG-Force | Ekim Gram Productions

Share on other sites
mod returns an integer correct, eg 5 mod 2 would be 1

well then if the original value is odd, it would end in .5 eg 5/2 is 2.5

well 2.5 - 1 is 1.5, not what you are looking for right.

edit: cant really offer advise as im not exactly sure what you want now

[edited by - ragamuffin on May 7, 2004 6:24:50 PM]

Share on other sites
<script language="javascript">time = new Date();hours = time.getHours();if (hours > 12)	hours = hours - 12;if (hours == 0)	hours = 12;minutes = time.getMinutes();if (minutes < 10)	minutes = "0" + minutes;document.write( hours + ":" + minutes );</script>

Share on other sites
Lol yeah i did put php in the topic. I been tryign to learn a bit of everything lately and i got a bit mixed up.

Favorite Quotes:Gandalf: You shall not pass!|Smeagol: We don''t need you!|Sloth: Hey you guys!|