PHP 에서 실 현 된 달력 기능 예시
<?php
/*
* Created by PhpStorm.
* User: admin
*/
header("Content-Type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
$a=@$_GET["a"];
$b=@$_GET["b"];
if($a){
$a=$a;
}else{
$a=date('y');
}
if($b){
$b=$b;
}else{
$b=date('m');
}
$noe=mktime(0,0,0,$b,1,$a); //
$year=date("Y",$noe); //
$month=date("m",$noe); //
$week=date("w",$noe); //
$days=date("t",$noe); //
$day=date("d"); //
$as=$year-1; //
$bs=$month-1; //
$bs=$month+1; //
$as=$year+1; //
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> </title>
<style>
table{
border: 1px solid #050;
}
table th{
background:#000;
color:#fff;
border: 2px solid #050;
}
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0">
<tr>
<th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" ><< </a></th>
<th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" ><< </a></th>
<th><?php echo $year."-".$month."-".$day ?></th>
<th><a href="?b=<?php echo $bs; ?>" rel="external nofollow" rel="external nofollow" > >></a></th>
<th><a href="?a=<?php echo $as; ?>" rel="external nofollow" rel="external nofollow" > >></a></th>
</tr>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
<tr>
<?php
for($i=0;$i<$week;$i++){
echo "<td> </td>"; //
}
for($k=1;$k<=$days;$k++){
if($k==$day){
echo "<th>".$k."</th>"; //
}else{
echo "<td>".$k."</td>"; //
}
if(($k+$week)%7==0){
echo "<tr></tr>"; //
}
}
?>
</tr>
</table>
</body>
</html>
실행 결과:PS:여기 서 몇 가지 시간 과 날짜 관련 도 구 를 추천 합 니 다.참고 하 시기 바 랍 니 다.
온라인 날짜/일수 계산기:
http://tools.jb51.net/jisuanqi/date_jisuanqi
온라인 날짜 계산기/차이 일수 계산기:
http://tools.jb51.net/jisuanqi/datecalc
온라인 날짜 일수 차 계산기:
http://tools.jb51.net/jisuanqi/onlinedatejsq
유 닉 스 타임 스탬프(timestamp)변환 도구:
http://tools.jb51.net/code/unixtime
더 많은 PHP 관련 내용 에 관심 이 있 는 독자 들 은 본 사이트 의 주 제 를 볼 수 있다.
본 논문 에서 말 한 것 이 여러분 의 PHP 프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
laravel에 yo에서 angularJs&coffeescript를 사용할 수 있도록 한다.먼저 yo 명령을 사용할 수 있어야하므로 아래에서 설치 global에 설치한 곳에서 laravel의 프로젝트 루트로 이동. 클라이언트 코드를 관리하는 디렉토리를 만들고 이동합니다. 클라이언트 환경 만들기 이것으로 히...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.