Jump to content

How to Get the Month?


morrisjohnny

Recommended Posts

In Reguards to the Month I Solved it I'm now having trouble Getting the Date as in the 1st or 27th ectAnyway I Have bene using the The code for getting the weekday ( from w3schools )From here To Do the Day & Month But i really can't figure out how to get the date since u they use the same variables or don't they? Someone exapling PLeaseCheers in advance-Jny Mris

Link to comment
Share on other sites

<html><body><script type="text/javascript">var d=new Date()var weekday=new Array(7)weekday[0]="Sunday"weekday[1]="Monday"weekday[2]="Tuesday"weekday[3]="Wednesday"weekday[4]="Thursday"weekday[5]="Friday"weekday[6]="Saturday"document.write("Today it is " + weekday[d.getDay()] + ", " + d.getDate());</script></body></html>

Link to comment
Share on other sites

If you want you could also use SSI (Server Side Includes). This can be done easily with HTML. I saw a thing on it before where it can get the weekday if you have two tags, not as complex and alot less code... Im not sure about the month though. I bet you can.. Just search HTML includes on google and look at them all until you find it!

Link to comment
Share on other sites

I don't think there is a code to directly output the 'st', 'nd', 'rd' and 'th' suffixes. Why not making your own code to put the correct suffix?

<script type="text/javascript">var d=new Date()var weekday=new Array(7)weekday[0]="Sunday"weekday[1]="Monday"weekday[2]="Tuesday"weekday[3]="Wednesday"weekday[4]="Thursday"weekday[5]="Friday"weekday[6]="Saturday"date = d.getDate();switch (date){case 1: suffix = 'st'; break;case 2: suffix = 'nd'; break;case 3: suffix = 'rd'; break;default: suffix = 'th';}document.write("Today it is " + weekday[d.getDay()] + ", " + date + suffix);</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...