Created
February 8, 2014 18:05
-
-
Save LESTADru/8887628 to your computer and use it in GitHub Desktop.
функцию formatDate(date), которая выводит дату date в формате дд.мм.гг:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>функцию formatDate(date), которая выводит дату date в формате дд.мм.гг:</title> | |
</head> | |
<body> | |
<script> | |
"use strict" | |
function formatDate(d){ | |
if(d.getMonth() < 9){ | |
var data = d.getDate() + "."+ 0 + ( +d.getMonth() + 1) + "." + d.getFullYear() ; | |
}else{ | |
var data = d.getDate() + "."+ ( +d.getMonth() + 1) + "." + d.getFullYear() ; | |
} | |
console.log(data); | |
return data; | |
} | |
var d = new Date(2011, 8, 30); // 30 января 2011 | |
alert( formatDate(d) ); // '30.01.11' | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment