PHP: Kwanaki Nawa har Kirsimeti?

Kirsimeti KareMuna da abokin harka wanda ke da wani abu na musamman wanda yake da kyau har zuwa Kirsimeti da saitin kwanuka har zuwa lokacin da karewa ya kasance a cikin filin da aka adana a cikin bayanan.

Ina buƙatar rubuta wani aikin cron (aikin da aka tsara) wanda ke sabunta filin don kowane gidan cin abincin su na dare. Ban taɓa yin rubutun kowane irin aikin ba kafin - godiya ga takwara na, Tim, a Imavex don jagorantata zuwa madaidaiciyar hanya. Har ma na samu ta email ta imel da safe don sanar da ni cewa ya ci nasara.

Ko ta yaya, Na hango tun lokacin da na rubuta lambar ko ta yaya, Zan iya raba cikin nishaɗin in fitar da shi zuwa gare ku 'yan uwa:

$ watan = 12;
$ kwana = 25;
$ shekara = kwanan wata ("Y");
$ days = (int) ((mktime (0,0,0, $ watan, $ rana, $ shekara) - lokaci (mara amfani)) / 86400);
idan ($ days> 0) {
$ shekara = $ shekara + 1;
$ days = (int) ((mktime (0,0,0, $ watan, $ rana, $ shekara) - lokaci (mara amfani)) / 86400);
}
sauya ($ days) {
case 0:
amsa kuwwa "Kirsimeti Kirsimeti!";
karya.
case 1:
amsa kuwa "Washegari Kirsimeti!";
karya.
tsoho:
amsa kuwwa "Akwai". $ kwana. "karin kwanaki har zuwa Kirsimeti!";
}

Hattara da kwafa da liƙawa daga gidan waya, wani lokacin manzannin zasu rikice. Idan kana da WordPress, a zahiri zaka iya saka wannan a cikin lambar shafinka kuma a nuna shi. Ban tabbata ba kowa yana farin ciki game da Kirsimeti kawai kasancewa kwanaki 48 daga baya, amma menene!

Idan kuna so, kuna iya gina bayanin bayanin har ma kuyi kwanaki 12 na Kirsimeti. 🙂

Wannan lambar kuma tana ɗaukar shekara cikin la'akari, don haka shekara mai zuwa zata ci gaba da aiki!

4 Comments

  1. 1
  2. 3

    Sannu Doug,

    Godiya ga wannan yanki na lambar. Trying Ina kokarin sanya shi a shafin goge na a matsayin widget. Na manna lambar a ciki kuma kawai tana nuna danyen lamba a shafin .. Ba zama matsafin php ba .. Shin akwai wata “hanya” mai sauƙi don sa ta yi aiki?

    Mun gode,
    Dan

Me kuke tunani?

Wannan shafin yana amfani da Akismet don rage spam. Koyi yadda aka sarrafa bayanan bayaninka.