Tempcode Symbol SEASON

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#5929 (In Topic #1413)
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
Tempcode symbol SEASON to show the season of the year.

sources/hooks/systems/symbols/SEASON.php

Code

<?php

class Hook_symbol_SEASON
{

    public function run($param)
    {
 // get today's date
$today = new DateTime();

// get the season dates
$spring = new DateTime('March 20');
$summer = new DateTime('June 20');
$fall = new DateTime('September 22');
$winter = new DateTime('December 21');

switch(true) {
    case $today >= $spring && $today < $summer:
        $value= 'Spring';
        break;

    case $today >= $summer && $today < $fall:
       $value= 'Summer';
        break;

    case $today >= $fall && $today < $winter:
        $value= 'Fall';
        break;

    default:
        $value= 'Winter';
}
        return $value;
    }
}

code from https://stackoverflow.com/questions/40893960/php-how-to-check-the-season-of-the-year-and-set-a-class-accordingly

usage:

Code

{$SEASON}

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#5931
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
I also made  sunrise & sunset tempcode symbols,

example:

Code

date_default_timezone_set("Asia/Tokyo");
$value = date("g:i a",(date_sunrise(time(),SUNFUNCS_RET_TIMESTAMP,43.4,141.21,90,9)));

info: https://www.w3schools.com/php/func_date_sunrise.asp

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#5932
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
for greeting of the day:

Code

<?php

class Hook_symbol_GREETING
{

    public function run($param)
    {
    //start

   date_default_timezone_set("Asia/Tokyo");
    $time = date("H");

   //  $timezone = date("e");

    if ($time < "12") {
return "morning";
    } else

    if ($time >= "12" && $time < "17") {
        return "afternoon";
    } else

    if ($time >= "17" && $time < "19") {
        return "evening";
    } else

    if ($time >= "19") {
        return "night";
    }



    }
}


code from https://stackoverflow.com/questions/8652502/run-code-depending-on-the-time-of-day
 

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Philip, gabriel58, Salman, amit.nigam, Manu, John Connor

Forum statistics:
  • 1,109 topics, 5,332 posts, 6,258 members
  • Our newest member is nicholasz
Birthdays:
Back to Top