We would like to know how to get day from Date as format '3-08-2015'.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
function GetDay(rawValue) {<!--from ww w . j av a 2 s .c o m-->
var parts = rawValue.split("-");
if (parts.length === 3) {
var day = parseInt(parts[0], 10);
if (!isNaN(day))
return day;
}
document.writeln("invalid date format");
return null;
}
document.writeln(GetDay("3-08-2015"));
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: