알림: 본 블로그는 'Clear Type'이 적용된 '맑은 고딕'글꼴을 사용합니다. 링크를 클릭하여 글꼴을 설치하시고 CT을 적용하세요.



개인적 필요로 D-day 출력 코드를 만들어봤습니다. (사실 전에 만들어 놓구서, 오늘 이곳에 붙이는거죠 ^-^)

코드 - 아주 간단합니다

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
function print_dday($dh=0,$dmin=0,$ds=0,$dm,$dd,$dy,$sg=false,$cl='red',$ds=true,$ad=true) {
  $dtime = floor((time()+32400)/86400);
  $dtemp = floor(mktime(0,0,0,$dm,$dd,$dy)/86400);
 
  $dday = $dtime - $dtemp - 1;
 
  if($dday > 0) {
    if($ad)
		$dday++;
	if($sg)
		$dday = "+".$dday;
  } else if($dday == 0) {
    if($ds) {
		$dday = D;
	} else {
		$dday = 0;
	}
  }
 
  if($dday%100 == 0 or (-5 < = $dday and $dday <= 0)) {
    $dday = "<font color='".$cl."'>".$dday."";
  }
 
  echo $dday;
}

파라미터 - 쓸데 없이 많습니다

$dh=0,$dmin=0,$ds=0 - 순서대로 D-day의 시, 분, 초를 입력
$dm,$dd,$dy - D-day의 월, 일, 년
$sg=false - 지난 D-day 표시시 true면 +부호를 포함
$cl=’red’ - D-day강조 색상. rgb코드 사용가능
$ds=true - true일 경우 D-day를 ‘D’로 표현하고, false이면 ‘0′으로 표현
$ad=true - 지난 D-day에 대해 표시하는 방법. true일 경우 D-day를 1일로 계산하고, false이면 D-day 다음날을 1일로 계산 (관련글: D데이 계산의 심오함)

저 코드 그대로 플러그인에다 넣어서 쓰고 있습니다. 워낙 간단하고 허접스런 암것도 아닌 코드라 플러그인이라고 부르기도 뭣해서 걍 코드만 올립니다. 남들은 AJAX에 effect에 다들 멋진것만 하는데, 전 주로 저런 자잘한 것들만 손댑니다. 그럼 ^-^

포스트가 유익했다면 구독 어떠세요? ( Subscribe in a reader | Add to Google Reader or Homepage | 한RSS에 추가 )




4개의 의견 @ “D-day 출력을 위한 php코드”

  1. 1 Sayuri   United States 

    :grin: a young korean blogger like myself! that knows php! *gasp*
    too bad i dont understand much of what you’re saying. but i got this: 파라미터 - 쓸데 없이 많습니다 equals “lots of useless parameters” kekeke. ^_^

    i hope you speak english? i suppose you’d have to. php is english…

  2. 2 park   Korea (South) 

    Sayuri// do i know php code? (what is *gasp*?) me? no way…. that(d-day code)’s not even a code. i feel everybody that knows just *echo* function will easily make that shit.

    well, my english? poor… poor… poor… (happily, not *suck* level.) however, if you say *korean-english a.k.a 콩글리쉬*? i’m sure i’m genius, kekeke.

    ps. you said *korean blogger like myself* and that means you’re korean, right? but your name ’sayuri’ sounds like japanese… is that a just nickname? and also, why don’t you tell me ur blog url?

  3. 3 Sayuri   United States 

    whenever you put a verb in between asteriks, it means that i’m doing that thing.. so *gasp* = i gasped… AOL lingo~

    konglish!! :D
    and yep, sayuri’s not my real name. i have a weird thing for keeping my identity secret… and i chose the name sayuri from memoirs of a geish ;D but since you’re korean… 내 이름은 오수연 입니다. haha my korean sucks..

    my blog’s not open yet, that’s why! :D

  4. 4 park   Korea (South) 

    Sayuri// thanx for comming again and AOL lingo.

    i hoped you’re japanese when i saw your name, sayuri, cuz i feel more comfortable when i say in japanese than english, kkk. :D
    ok… yep, i’ve just known your korean real name. (keeping ur identity? weired but ok cuz we’re in the web. and, also, in that point of view, i’m weird too.)

    anyway, welcome to my world…

의견 남기기

:mrgreen: :neutral: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :mad: :sad:

스팸방지 정책상 최초의 의견등록시 운영자의 승인후 목록에 공개됩니다


태그 알림 쓸 수 있는 HTML 태그:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">