mcarlson
05-16-2012, 12:25 AM
I'm trying to find a way to display a future date in short format (as an expiration date) with Javascript. I've figured out how to do it with long format, but have no idea how to convert it and I'm not great with Javascript.
Here is code that I found on another forum and modified:
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<!doctype html>
<head>
<title>Expires</title>
</head>
<body>
<script>
var myDelayInDays=6, myDate=new Date();
myDate.setDate(myDate.getDate()+myDelayInDays);
document.write('Expires: ' + myDate.toLocaleDateString());
</script>
</body>
</html>
</body>
</html>
Which displays:
"Expires: Monday, May 21, 2012"
I would like it to display:
"Expires: 05/21/2012"
Can anyone help?!
Here is code that I found on another forum and modified:
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<!doctype html>
<head>
<title>Expires</title>
</head>
<body>
<script>
var myDelayInDays=6, myDate=new Date();
myDate.setDate(myDate.getDate()+myDelayInDays);
document.write('Expires: ' + myDate.toLocaleDateString());
</script>
</body>
</html>
</body>
</html>
Which displays:
"Expires: Monday, May 21, 2012"
I would like it to display:
"Expires: 05/21/2012"
Can anyone help?!