Possible Duplicate:
Javascript add leading zeroes to date
It might be a simple question because I am still newbie in JavaScript, assume I have DateTime in ISO format:
 2012-07-07T17:00:00
I would like to format this date to string:
 07.07.2012
I have written a function to format to 7.7.2012 as below:
var formatDate = function (datum) {
    var date = new Date(datum);
    return date.getDate() + '.' + (date.getMonth() + 1) + '.' + date.getFullYear();
};
How can I modify this code to get the result 07.07.2012 instead of 7.7.2012
This might be helpful.
<script type="text/javascript">
    var date=new Date();
    day=date.getDate();
    month=date.getMonth();
    month=month+1;
    if((String(day)).length==1)
    day='0'+day;
    if((String(month)).length==1)
    month='0'+month;
    dateT=day+ '.' + month + '.' + date.getFullYear();
    //dateT=String(dateT);
    alert(dateT);
</script>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With