Skip to content

Instantly share code, notes, and snippets.

@chris4403
Created March 28, 2013 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris4403/5263889 to your computer and use it in GitHub Desktop.
Save chris4403/5263889 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
var p = function(num) {
return ((num + "").length == 1) ? "0" + num : num;
}
var now = new Date();
$('#d1').val(now); //NG
$('#d2').val('2013-3-6'); //NG
$('#d3').val('2013-3-07'); //NG
$('#d4').val('2013-03-07'); //OK
$('#d5').val('2013/03/07'); //NG
$('#d6').val(now.getFullYear() + '-' + p(now.getMonth() + 1) + '-' + p(now.getDate())); // TODAY
$('#v6').val($('#d4').val());
});
</script>
</head>
<body>
<input id="d1" type="date" value="">
<input id="d2" type="date" value="">
<input id="d3" type="date" value="">
<input id="d4" type="date" value="">
<input id="d5" type="date" value="">
<input id="d6" type="date" value="">
<br/>
value : <input id="v6" type="text" value="">
</body>
</html>
@noromanba
Copy link

@chris4403 👍

google-chrome-on-linux

Debian GNU/Linux 3.4.4 wheezy/sid (Knoppix V7.0.3 JA-LCR)

chrome://version
| Google Chrome | 26.0.1410.63 (Official Build 192696) |
| OS            | Linux                                |
| WebKit        | 537.31 (@147513)                     |
| JavaScript    | V8 3.16.14.11                        |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment