Isaac
asked on
Extract date
I'm trying to use the code below to extract the date with out the time.
The result I get is 1st of April with a time stamp still.
The result I get is 1st of April with a time stamp still.
<script type="text/javascript">
<!--
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
document.getElementsByName('SubscriberDate')[0].value = ("0" +
curr_month).slice(-2) + "/" + curr_year;//-->
</script>
ASKER
How do I get it to display the full date?
Thanks!
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to learn more about dates in Javascript, you might be interested in this article:
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_484-Can-I-have-a-date.html
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_484-Can-I-have-a-date.html
This code displays 04/2012 in IE, Chrome and FF.
<script type="text/javascript">
var d = new Date();
var m = d.getMonth() + 1;
var y = d.getFullYear();
if (m < 10) {
document.write('0');
}
document.write(m + '/' + y);
</script>
I ran your code and got an error at the .slice. All I saw on my screen was '04'.