Hello, I would like to know how do I instert the date in my website in format: October 2, 2008 What code should I use and where should I insert it? Thanks
Its a little line of javascript, which I dont remember offhand. Try posting the ? in the Javascript forum, someone there should be able to give you the code. Or just google something like "javascript display date" and see what you get.
in javascript you can use this to display the date var currentDate = new Date() var day = currentDate.getDate() var month = currentDate.getMonth() var year = currentDate.getFullYear() document.write("<b>" + month+ "/" + day + "/" + year + "</b>") Code (markup):
Yes You will have to add < script > tags .. heres the full code > <script language="javascript"> var currentDate = new Date() var day = currentDate.getDate() var month = currentDate.getMonth() var year = currentDate.getFullYear() document.write("<b>" + month+ "/" + day + "/" + year + "</b>") </script> Code (markup):
My code in above post , displays the date in digits only, if you want the name of month, day etc to appear, use this code > <script language="JavaScript"> <!-- var now = new Date(); var days = new Array( 'Sunday','Monday','Tuesday', 'Wednesday','Thursday','Friday','Saturday'); var months = new Array( 'January','February','March','April','May', 'June','July','August','September','October', 'November','December'); var date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); function fourdigits(number) { return (number < 1000) ? number + 1900 : number;} today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())); document.write(today); //--> </script> Code (markup): Hope this helps
I like the PHP route myself: <?php echo(date("Y/m/d")); ?> Code (markup): However, it'd assume you'd be embedding it on a page which is being run through PHP (such as .php or the like)
I would like to know how to add an ZERO "0" for months with one digit --- <script language="javascript"> var currentDate = new Date() var day = currentDate.getDate() var month = currentDate.getMonth() var year = currentDate.getFullYear() document.write("<b>" + month+ "/" + day + "/" + year + "</b>") </script> Can I add the time in the same simple form? Thank you!