메뉴 건너뛰기

프로그램언어

조회 수 413 추천 수 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 버전 숨기기 ( php version hide )

    Date2024.02.07 Views79
    Read More
  2. php 두날짜 사이의 모든날짜 배열 만들기

    Date2023.01.12 Views188
    Read More
  3. PHP str_replace php 문자열치환

    Date2023.01.12 Views202
    Read More
  4. PHP 이미지 리사이즈 함수 imagecopyresized

    Date2023.01.12 Views214
    Read More
  5. HTTP 인증하기, 로그인창 띄우기

    Date2021.03.26 Views215
    Read More
  6. [PHP기초] 상속기본

    Date2021.03.27 Views215
    Read More
  7. 코드 생성 하기

    Date2023.01.12 Views216
    Read More
  8. 폴더 용량 체크

    Date2023.01.12 Views225
    Read More
  9. PHP SimpleHtmlDom Parser로 HTML 파싱하기

    Date2023.01.12 Views225
    Read More
  10. 조건문의 함수실행 여부 if ( 0 && ... )

    Date2021.03.26 Views229
    Read More
  11. ereg(), eregi(), ereg_replace(), eregi_replace(), split() 대체

    Date2023.01.12 Views231
    Read More
  12. PHP 파일 업로드 FORM 처리

    Date2023.01.12 Views233
    Read More
  13. 배열 연산자 []= 에 대해서

    Date2021.03.26 Views234
    Read More
  14. 클래스와 인스턴스 그리고 메소드 만들기

    Date2021.03.27 Views235
    Read More
  15. 웹페이지 파싱

    Date2023.01.12 Views236
    Read More
  16. PHP 디렉토리안에 파일 리스트 가져오기

    Date2023.01.12 Views237
    Read More
  17. php www 붙이기

    Date2023.01.12 Views239
    Read More
  18. 상수, 마법상수, 모든 상수 보기

    Date2021.03.26 Views240
    Read More
  19. PHP http -> https 로 전환

    Date2023.01.12 Views240
    Read More
  20. PHP 하위 디렉토리 포함 디렉토리 리스트 출력

    Date2023.01.12 Views240
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved