Forum Moderators: open
I found JS code to post todays date in that format on IRT.org except that it only prints the code to the page. I need to put the JS code in the header and then call it through hidden form fields when needed. This is the code I found for todays date:
<script language="JavaScript"><!--
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;document.write(day + "/" + month + "/" + year);
//--></script>
Any tips?
e.g.
Instead of
document.write(day + "/" + month + "/" + year);
try
var myDateString = (day + '\/' + month + '\/' + year);
Ive escaped the slashes and (in keeping with the rest of the code) used single quotes
Oh... and its not
<script language="JavaScript">
its
<script type="text/javascript">
One question:
What will happen when visitors have scripts turned off?
One suggestion:
Consider php dates - they're implemented server side :)
Results 1 - 100 of about 29,800 from webmasterworld.com for php date [google.com]
Rather, you should feel proud that you are willing to ask for and accept advice
As there's a heap of stuff that that I don't know and you probably/possibly either know it already or will learn it soon, please do subscribe to the relevant forums and be ready to help me when I ask for help :)