메뉴 건너뛰기

프로그램언어

조회 수 411 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>성공</title>

<style>
 
#main{
border: black 1px solid;
}
#calendar{
border: black 1px solid;
}
 
th,tr,td{
border: black 1px solid;
}
 
</style>
</head>
<body>
<h1 align="center">달력 만들기 - 부제 코딩 습관</h1>
 
<h4>1. defaults 로 설정되어있는 현재 시간. 객체다</h4>
 
<?php $date = new DateTime(); print_r($date); ?> <br>
 
<?php echo $date->date; ?> <br>
 
<?php echo $date->getTimestamp(); ?> <br>


 
<h4>2. int time ( void ) 함수 1970년 1월 1일 0시 0분 0초부터 지금까지 지나온 초를 정수형태로 리턴</h4>
 
<?php
 
$now_titmestamp = time();
 
echo $now_titmestamp;
 
?>
 
<h4>3. date()는 time()으로 구해진 타임스탬프를 읽기 좋게 포멧팅</h4>
 
<?php
 
$now_titmestamp = time();
 
echo date("Y-m-d h:i:s",$now_titmestamp);
 
?>

<h4>4. mktime()은 날짜정보를 입력해서 타임스탬프를 구할 수 있는 함수</h4>
 
<?php
$sec = mktime(0, 0, 0, 9, 1, 2017);
echo '1970년 1월 1일 0시 0분 0초부터 9월 1일 까지의 초:'.$sec;
echo '<br>';
 
$sec = mktime(0, 0, 0, 9, 1, 2017);
$yoil=date("D",$sec);
echo '9월 첫째 요일:'.$yoil;
echo '<br>';
 
$sec = mktime(0, 0, 0, 9, 1, 2017);
$firstyouil=date("j",$sec);
echo '9월 첫째 날짜:'.$firstyouil;
echo '<br>';
 
$sec = mktime(0, 0, 0, 9, 1, 2017);
$lastday=date("t",$sec);
echo '9월 마지막 날짜:'.$lastday;
echo '<br>';

$sec = mktime(0, 0, 0, 9, $lastday, 2017);
$lastyouil=date("D",$sec);
echo '9월 마지막 날짜 요일:'.$lastyouil;
echo '<br>';

$now_time = time();
$month=date("n",$now_time);
echo '이번달은'.$month.'월입니다';
echo '<br>';
 
$now_time = time();
$week=date("W",$now_time);
echo '이번주는'.$week.'번째 주입니다';
echo '<br>';
 
//0 (for Sunday) through 6 (for Saturday)
$now_time = time();
$todayyoil=date("w",$now_time);
echo '오늘은'.$todayyoil.'요일 입니다';
echo '<br>';

 
$daily = array('일','월','화','수','목','금','토');
$date5 = date('w'); //0 ~ 6 숫자 반환
echo $daily[$date5];
 
?><br>





 
<h4>5. 날짜 설정하기</h4>
 
<?php $date = new DateTime('tomorrow'); print_r($date); ?> <br>
 
<?php $date = new DateTime('March 24,2013'); print_r($date); ?> <br>


 
<h4>6. 날짜 비교하기1</h4>
 
<?php
$one = new DateTime('tomorrow');
$two = new DateTime('March 24,2013');
 
if($one > $two)
{
echo "one 이 two 보다 큽니다 <br>";
}
 
$diff = $one -> diff($two); print_r($diff);
?><br>


 
<h4>7. 날짜 비교하기2</h4>
 
<?php
$date1=date_create("2013-01-01");
$date2=date_create("2013-02-10");
$diff=date_diff($date1,$date2);
 
// %a outputs the total number of days
echo $diff->format("총 날짜: %a.");
echo "<br>";
 
// %R outputs + beacause $date2 is after $date1 (a positive interval)
echo $diff->format("총날짜: %R%a.");
echo "<br>";
 
// %d outputs the number of days that is not already covered by the month
echo $diff->format("Month: %m, days: %d.");
?>
 
<br>

<h4>8. 요일 구하기</h4>
 
<?php
$daily = array('일','월','화','수','목','금','토');
$date = date('w'); //0 ~ 6 숫자 반환
echo $daily[$date];
?>

<h4>9. 타임존</h4>
 
<?php $date3 = new DateTime('now', new DateTimeZone('Asia/Seoul')); print_r($date3); ?><br>
<?php echo $date3->format("Y-m-d H:i"); ?><br>

<?php $date3 = new DateTime('yesterday'); echo '어제 날짜:'.$date3->format("Y-m-d");?><br>
<?php echo '오늘 날짜:'.$date3->format("Y-m-d"); ?><br>
<?php $date3 = new DateTime('tomorrow'); echo '내일 날짜:'.$date3->format("Y-m-d");?>



 
<h4>10. dateperiod 사용하기</h4>
<?php $period = new dateperiod($two , new DateInterval('P3D'), $one);
 
foreach($period as $datetime){
 
printf('<li>%s</li>',$datetime ->format('Y-m-d'));
}
 
?>
<?php
 
$yoyill = array("일","월","화","수","목","금","토");
 
?>

<div id="main">
<div id="top" align="center">
<span> 2017-9-22</span>
</div>

<div id="content" align="center">
<table id="calendar">
<tr>
<?php
$daily = array('일','월','화','수','목','금','토');
$today_yoil = date('w'); //0 ~ 6 숫자 반환
 
for($i=0;$i<7;$i++){
?>
 
<th> <?php echo $daily[$i]; ?></th>
 
<?php
}
?>
 
</tr>
 
<!-- 요일 부분 끝 -->

<?php //줄
for($i1=0; $i1<5;$i1++){
 
?>
<tr>
 
<?php //칸
 
for($i2=0;$i2<7;$i2++){
 
//if(){
?>
<td><?php echo $i2; ?></td>
 
<?php
//}
}
?>
 
</tr>
<?php
}
?>
 
</table>
 
</div>
 
</div>

<?php //9월 1일 부터 30일
$daily = array('일','월','화','수','목','금','토');
$sec = mktime(0, 0, 0, 9, 1, 2017);
$firstday=date("j",$sec); //1
$lastday=date("t",$sec); //30
$firstyoil=date("w",$sec); //5 //금
?>
 
<div id="content" align="center">
<table id="calendar">
<tr>
<?php
$daily_ = array('일','월','화','수','목','금','토');
$today_yoil = date('w'); //0 ~ 6 숫자 반환
 
for($i=0;$i<7;$i++){
?>
 
<th> <?php echo $daily_[$i]; ?></th>
 
<?php
}
?>
 
</tr>
</table>
 
<table>
<?php
// 요일 부분 끝
 
echo '<tr>';
for($firstday;$firstday<$lastday+1;$firstday++){
 
 
 

echo $firstday.' : ' ; // 1
$sec_yoil = mktime(0, 0, 0, 9, $firstday, 2017);
$yoil=date("w",$sec_yoil);
echo $daily[$yoil].'<br>'; //5
};
 
 
 
?>
</table>

</div>
 
</body>
</html>

 

 


  1. PHP 이미지 리사이즈 함수 imagecopyresized

    Date2023.01.12 Views212
    Read More
  2. PHP http -> https 로 전환

    Date2023.01.12 Views236
    Read More
  3. PHP - 공공 DATA XML 파싱(PHP 버전)

    Date2023.01.12 Views269
    Read More
  4. php www 붙이기

    Date2023.01.12 Views234
    Read More
  5. 주차 , 요일, 해당주의 시작일, 해당주의 종료일 date()

    Date2021.07.08 Views432
    Read More
  6. 특정일의 주차 구하기

    Date2021.07.08 Views322
    Read More
  7. 날짜함수 사용하여 한달에 주차 구하기 weeks by month

    Date2021.07.08 Views695
    Read More
  8. CodeIgniter - DB오류체크, 디버깅 여부 설정

    Date2021.03.29 Views494
    Read More
  9. [PHP기초] 함수와 객체의 비교

    Date2021.03.27 Views291
    Read More
  10. 클래스와 인스턴스 그리고 메소드 만들기

    Date2021.03.27 Views231
    Read More
  11. [PHP기초] 생성자(인스턴스 초기화)

    Date2021.03.27 Views265
    Read More
  12. [PHP기초] 접근제어자(access modifier)

    Date2021.03.27 Views283
    Read More
  13. [PHP기초] 상속기본

    Date2021.03.27 Views214
    Read More
  14. [PHP기초] 데이터 집합 - 배열다루기

    Date2021.03.27 Views263
    Read More
  15. [PHP 기초] 함수에 관해서

    Date2021.03.27 Views268
    Read More
  16. php date 날짜 관련 함수

    Date2021.03.27 Views411
    Read More
  17. AJAX로 해당 페이지에서 COOKIE 사용하기

    Date2021.03.26 Views359
    Read More
  18. 파일 output을 return 하기

    Date2021.03.26 Views243
    Read More
  19. MYSQL DB 다중접속을 해결 하는 한 방법

    Date2021.03.26 Views284
    Read More
  20. PHP 쉘 스크립트

    Date2021.03.26 Views457
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved