戻る

解答例

JavaScript

月は-1で数える

<!DOCTYPE HTML>
<html lang="ja-JP">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
var timestamp = "";

timestamp += "2006年9月1日のタイムスタンプ<br>";
timestamp += Math.round((new Date(2006,8,1,0,0,0,0)).getTime() / 1000) + "<br><br>";

timestamp += "2006年10月15日のタイムスタンプ<br>";
timestamp += Math.round((new Date(2006,9,15,0,0,0,0)).getTime() / 1000) + "<br><br>";

timestamp += "2006年11月3日12時10分15秒のタイムスタンプ<br>";
timestamp += Math.round((new Date(2006,10,3,12,10,15,0)).getTime() / 1000) + "<br><br>";

timestamp += "2006年11月3日12時10分16秒のタイムスタンプ<br>";
timestamp += Math.round((new Date(2006,10,3,12,10,16,0)).getTime() / 1000) + "<br><br>";

document.getElementsByTagName("body")[0].innerHTML = timestamp;
</script>
</html>

PHP

<?php
header("Content-type: text/html; charset=utf-8");

date_default_timezone_set("Asia/Tokyo");

echo "2006年9月1日のタイムスタンプ<br>";
echo mktime(0,0,0,9,1,2006) . "<br><br>";

echo "2006年10月15日のタイムスタンプ<br>";
echo mktime(0,0,0,10,15,2006) . "<br><br>";

echo "2006年11月3日12時10分15秒のタイムスタンプ<br>";
echo mktime(12,10,15,11,3,2006) . "<br><br>";

echo "2006年11月3日12時10分16秒のタイムスタンプ<br>";
echo mktime(12,10,16,11,3,2006);
?>

inserted by FC2 system