PHP: Muaj pes tsawg hnub kom txog thaum Christmas?

Christmas AubPeb muaj cov neeg siv khoom uas muaj qhov tshwj xeeb uas tsuas yog ua tau zoo kom txog Christmas thiab kev teeb tsa rau cov hnub kom txog thaum tas sij hawm nyob hauv ib daim teb uas tau khaws cia hauv cov chaw khaws ntaub ntawv.

Kuv yuav tsum tau sau ib txoj haujlwm cron (tau npaj ua haujlwm) uas hloov thaj teb rau lawv txhua lub tsev noj mov nyob hauv ib hmos. Kuv tsis tau hais dua ib qho kev ua haujlwm cron ua ntej - ua tsaug rau kuv cov npoj yaig, Tim, ntawm Imavex rau coj kuv txoj hauv kev. Kuv twb tau txais nws email rau kuv thaum sawv ntxov los qhia rau kuv paub tias nws ua tiav.

Xijpeem, Kuv xav tau txij li thaum kuv tau sau cov cai li cas los xij, Kuv tuaj yeem sib koom kev lom zem thiab muab nws tawm mus rau koj:

$ hli = 12;
$ hnub = 25;
$ xyoo = hnub ("Y");
$ hnub = (int) ((mktime (0,0,0, $ hli, $ hnub, $ xyoo) - lub sijhawm (khoob)) / 86400);
yog ($ hnub> 0) {
$ xyoo = $ xyoo + 1;
$ hnub = (int) ((mktime (0,0,0, $ hli, $ hnub, $ xyoo) - lub sijhawm (khoob)) / 86400);
}
hloov ($ hnub) {
rooj plaub 0:
ncha "Zoo siab Christmas!";
tawg;
rooj plaub 1:
ncha "Yog Hnub Christmas!";
tawg;
vim:
ncha "Muaj". $ hnub. "ntau hnub ntxiv txog Christmas!";
}

Ceev faj ntawm daim ntawv luam thiab luam tawm ntawm cov kab ntawv, qee zaum cov lus qhia tsis sib haum. Yog tias koj muaj WordPress, koj tuaj yeem nkag qhov no rau hauv cov cai ntawm koj nplooj ntawv thiab muaj nws tso saib. Kuv tsis paub meej tias txhua tus neeg zoo siab txog Christmas tsuas yog 48 hnub nyob deb, tab sis dab tsi los ua dab tsi!

Yog tias koj xav tau, koj tuaj yeem tsim tsa rooj plaub hais thiab ua 12 Hnub Christmas. 🙂

Tus lej no tseem siv sijhawm xyoo rau kev txiav txim siab, yog li lwm xyoo nws tseem yuav ua haujlwm ntxiv!

4 Comments

  1. 1
  2. 3

    Kuv tuaj los Doug,

    Ua tsaug rau qhov snippet ntawm code. 🙂 Kuv sim muab nws tso rau ntawm kuv qhov blog sidebar uas yog qhov khoom siv dav. Kuv yav dhau los cov cai hauv thiab nws tsuas yog qhia cov lej nyoos ntawm nplooj ntawv .. Tsis yog ib qho php wizard .. Puas muaj ib txoj hauv kev "yooj yim" kom nws ua haujlwm?

    thanks,
    Dan

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.