Jump to content
  • Advertisement

Archived

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

SSJCORY

PHP date question.

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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!|

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!