## 기간 일 구하기

1
echo intval((strtotime(종료일) - strtotime(시작일)) / 86400);


## 날짜 몇분전 으로 표시

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// $date1:기준시간  timestamp
// $date2:계산할시간 timestamp
function getGlobalDate($date1, $date2) {
    $dtDiff = $date1 - $date2;
     
    if($dtDiff < 60) $rs = intval($dtDiff) . "/sec";
    else if($dtDiff < 60*60) $rs = intval($dtDiff / (60)) . "/min";
    else if($dtDiff < 60*60*24) $rs = intval($dtDiff / (60*60)) . "/hour";
    else if($dtDiff < 60*60*24*7) $rs = intval($dtDiff / (60*60*24)) . "/day";
    else if($dtDiff < 60*60*24*30) $rs = intval($dtDiff / (60*60*24*7)) . "/week";
    else if($dtDiff < 60*60*24*365) $rs = intval($dtDiff / (60*60*24*30)) . "/month";
    else $rs = intval($dtDiff / (60*60*24*365)) . "/year";
     
    return $rs;
}


## 남은시간 계산

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
설  명
    해당시간의 남은시간 계산함수
    사용예
        diff_time(timestamp)
        리턴값
        배열
*/
function diff_time( $timestamp ) {
    $date1 = $timestamp;
    $date2 = time();
    $total_secs = abs($date1-$date2);
    $diff_in_days = floor( $total_secs / 86400 );
    $rest_hours = $total_secs % 86400;
    $diff_in_hours = floor( $rest_hours / 3600 );
    $rest_mins = $rest_hours % 3600;
    $diff_in_mins = floor( $rest_mins / 60 );
    $diff_in_secs = floor( $rest_mins % 60 );
 
    $time_diff["days"] = (int)($diff_in_days);
    $time_diff["hours"] = $diff_in_hours;
    $time_diff["mins"] = $diff_in_mins;
    $time_diff["secs"] = $diff_in_secs;
    return $time_diff;
}


## 한시간 전 날짜와 시간 구하기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
echo date("Y-m-d H:i:s", mktime(date("H")-1, date("i"), date("s"), date("m"), date("d"), date("Y")));
 
15일전 날짜 구하기
$date = date('Y-m-d H:i:s', strtotime('-15 day'));
 
타임스템프 변환
$sch_end_date = '2017-01-30 23:59:59';
$timestamp strtotime($sch_end_date);
echo date('Y-m-d H:i:s', $timestamp); exit;
 
 
$time = time();
date("Y-m-d",strtotime("-1 day", $time)); // 하루 전(어제)
date("Y-m-d",strtotime("-1 day", $time)); // 하루 전(어제)
date("Y-m-d",strtotime("now", $time)); // 현재
date("Y-m-d",strtotime("+1 day", $time)); // 하루 후(내일)
date("Y-m-d",strtotime("+1 week", $time)); // 일주일 후
date("Y-m-d",strtotime("-1 month", $time)); // 한달 전
date("Y-m-d",strtotime("+1 month", $time)); // 다음달
date("Y-m-d",strtotime("+6 month", $time)); // 6달후
date("Y-m-d",strtotime("+12 month", $time)); // 12달후
date("Y-m-d",strtotime("next Thursday", $time)); // 다음주 목요일
date("Y-m-d",strtotime("last Monday", $time)); // 지난 월요일
date("Y-m-d",strtotime("10 September 2000", $time)); // 2000년 9월 10일
date("Y-m-d", strtotime('first day of')) // 해당월의 1일
date("Y-m-d:i:s", strtotime("now", $time)); //현재 시간
date("Y-m-d:i:s", strtotime("+5 minutes", $time)); //현재 시간에서 5분 후


## 한주의 시작일과 마지막일 구하기

1
2
3
4
5
6
7
8
9
$today = date("Ymd");
 
$week_day = date("w", mktime(0, 0, 0, substr($today, 4, 2), substr($today, 6, 2), substr($today, 0, 4)) );
$week_start = date("Ymd", mktime(0, 0, 0, substr($today, 4, 2), substr($today, 6, 2)-$week_day, substr($today, 0, 4)) );
 
$week_day2 = 6 - $week_day;
$week_end = date("Ymd", mktime(0, 0, 0, substr($today, 4, 2), substr($today, 6, 2)+$week_day2, substr($today, 0, 4)) );
 
echo $week_start ."~". $week_end;


'프로그래밍 > php' 카테고리의 다른 글

PHP Simple HTML DOM Parser  (0) 2018.02.27
정규식 예제  (0) 2018.02.27
컨텐츠 내용중 첫번째 IMG주소 뽑아내기  (0) 2018.02.27
GD  (0) 2018.02.27
captcha  (0) 2018.02.27


1.  syntaxhighlighter_3.0.83.zip파일 압축해제


2. 티스토리ADMIN -> 꾸미기 -> 스킨편집 -> html편집 


- 파일 업로드 탭 

script. style 파일 모두 업로드

-  HTML 탭

</head>안에 아래 내용 삽입 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!--link href="./images/shThemeDefault.css" rel="stylesheet" type="text/css"/-->
<link href="./images/shThemeRDark.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./images/shCore.js"></script>
<script type="text/javascript" src="./images/shBrushJScript.js"></script>
<script type="text/javascript" src="./images/shLegacy.js"></script>
<script type="text/javascript" src="./images/shBrushBash.js"></script>
<script type="text/javascript" src="./images/shBrushCpp.js"></script>
<script type="text/javascript" src="./images/shBrushCSharp.js"></script>
<script type="text/javascript" src="./images/shBrushCss.js"></script>
<script type="text/javascript" src="./images/shBrushDelphi.js"></script>
<script type="text/javascript" src="./images/shBrushDiff.js"></script>
<script type="text/javascript" src="./images/shBrushGroovy.js"></script>
<script type="text/javascript" src="./images/shBrushJava.js"></script>
<script type="text/javascript" src="./images/shBrushPhp.js"></script>
<script type="text/javascript" src="./images/shBrushPlain.js"></script>
<script type="text/javascript" src="./images/shBrushPython.js"></script>
<script type="text/javascript" src="./images/shBrushRuby.js"></script>
<script type="text/javascript" src="./images/shBrushScala.js"></script>
<script type="text/javascript" src="./images/shBrushSql.js"></script>
<script type="text/javascript" src="./images/shBrushVb.js"></script>
<script type="text/javascript" src="./images/shBrushXml.js"></script>
<script type="text/javascript">
  //SyntaxHighlighter.defaults["toolbar"] = false; // 툴바없애기
  //SyntaxHighlighter.defaults["auto-links"] = false; // 자동 링크없애기
  //SyntaxHighlighter.defaults["tab-size"] = 2; // 탭사이즈를 2로 설정
  SyntaxHighlighter.all();
</script>


'기타' 카테고리의 다른 글

윈도우 메모리 관리 툴 - RAMMAP  (0) 2018.03.08
SyntaxHighlighter 옵션  (0) 2018.02.27

Configuration

NameValueDescription
bloggerModefalseblogger.com 에서 사용중이라면 
true로 설정할 것
clipboardSwfnullclipboard로 사용할 url을 적는다.
stringsObject각종 메시지를 재정의할 수 있다.
자세한 설정Viewer을 참조 +_+
stripBrsfalsebr 태그 무시 여부 결정
toolbarItemWidth16툴바 아이템 가로 크기
toolbarItemHeight16툴바 아이템 세로 크기
tagName"pre"다른 태그를 사용하고 싶다면 설정.


위의 설정을 Syntax highlighter 로드하는 js 안에 입력하여 사용.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false; // 툴바 설정 (기본값 True)
//SyntaxHighlighter.defaults['gutter'] = true; // 라인 번호 설정 (기본값 True)
//SyntaxHighlighter.defaults['tab-size'] = 2; // 탭 사이즈 설정 (기본값 4)
//SyntaxHighlighter.defaults['first-line'] = 1; // 라인 시작 숫자 (기본값 1)
//SyntaxHighlighter.defaults['auto-links'] = false; // 링크 설정 (기본값 true)
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
//SyntaxHighlighter.config.stripBrs = true;
.
.
.
 
SyntaxHighlighter.all()
</script>


Default

각종 기본 설정을 재정의할 수 있다.

NameValueDescription
auto-linkstrueurl 등이 있을때 자동으로 링크 걸어주는지 여부
class-name''custom class 사용시 설정
collapsefalsecollapse로 사용할 것인가? 
view source등을 클릭해야 소스가 보이도록..
first-line1첫 라인의 라인넘버
guttertrue라인넘버 보이도록?
highlightnull라인별로 강조하고 싶은 경우
[1, 2, 3] 또는 해당 라인넘버
html-scriptfalse스크립트(php, jsp 등)에 포함된 HTML/XML을 하이라이트 할 것인가 여부,
true로 설정하면 반드시 shBrushXml.js를 로드하여야 한다.
lightfalsetoolbar + gutter 를 한 옵션으로 처리할 때 사용.
smart-tabstrue스마트 탭 사용 여부
tab-size4탭 크기.
toolbartrue툴바 켜고 끄기
wrap-linestrue줄바꿈 할 것인지 설정


- 기본 설정은 default에 정의 하여 아래와 같이사용할 수 있으며

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false; // 툴바 설정 (기본값 True)
SyntaxHighlighter.defaults['gutter'] = true; // 라인 번호 설정 (기본값 True)
SyntaxHighlighter.defaults['tab-size'] = 2; // 탭 사이즈 설정 (기본값 4)
SyntaxHighlighter.defaults['first-line'] = 1; // 라인 시작 숫자 (기본값 1)
SyntaxHighlighter.defaults['auto-links'] = false; // 링크 설정 (기본값 true)
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.stripBrs = true;
.
.
.
 
SyntaxHighlighter.all()
</script>


만약 여러가지 옵션을 동시에 지정하고 싶을 경우 세미콜론(;)으로 구분하여 연속으로 지정하면 됩니다

1
<pre class="brush: js; ruler: true; first-line: 10; highlight: [2, 4, 6]">...</pre>


brush 종류

Brush nameBrush aliasesFile name
ActionScript3Vieweras3, actionscript3shBrushAS3.js
Bash/shellViewerbash, shellshBrushBash.js
C#Viewerc-sharp, csharpshBrushCSharp.js
C++Viewercpp, cshBrushCpp.js
CSSViewercssshBrushCss.js
DelphiViewerdelphi, pas, pascalshBrushDelphi.js
DiffViewerdiff, patchshBrushDiff.js
GroovyViewergroovyshBrushGroovy.js
JavaScriptViewerjs, jscript, javascriptshBrushJScript.js
JavaViewerjavashBrushJava.js
JavaFXViewerjfx, javafxshBrushJavaFX.js
PerlViewerperl, plshBrushPerl.js
PHPViewerphpshBrushPhp.js
Plain TextViewerplain, textshBrushPlain.js
PowerShellViewerps, powershellshBrushPowerShell.js
PythonViewerpy, pythonshBrushPython.js
RubyViewerrails, ror, rubyshBrushRuby.js
ScalaViewerscalashBrushScala.js
SQLViewersqlshBrushSql.js
Visual BasicViewervb, vbnetshBrushVb.js
XMLViewerxml, xhtml, xslt, html, xhtmlshBrushXml.js



소스코드를 입력할때 주의해야할 사항은 꺽쇠 <>를 변환해줘야 합니다.

만약 그대로 꺽쇠를 작성하면 제대로 동작하지 않을 수 있습니다.

하지만 이러한 꺽쇠를 그때그때 수정해야 하면 너무 번거롭기 때문에

꺽쇠를 자동으로 변환해주는 사이트를 소개하며 포스팅을 마치겠습니다.

 

parkjuwan 사이트 : (http://parkjuwan.dothome.co.kr/webapp/ltgt_conv/)



출처 : http://chongmoa.com/webtool/3007

'기타' 카테고리의 다른 글

윈도우 메모리 관리 툴 - RAMMAP  (0) 2018.03.08
SyntaxHighlighter 셋팅  (0) 2018.02.27

+ Recent posts