1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

PHP help with Script - display the Year only

Discussion in 'Community' started by stevelis, Jul 10, 2019.

Thread Status:
Not open for further replies.
  1. stevelis

    stevelis Member

    Level: Community
    The script below is part of a php file that is used in a Fabrik schedule plugin which is working fine with the year (2019) typed as plain text.
    Can anybody assist with the code/function I should use that will automatically change the year, rather than open the file manually and change the text to the following year.
    BTW the startDate and endDate only displays the day and month

    <b>Hi {$steward->FName},</b>
    <br>Your next stewarding event is {$row->calendar___Event} at {$row->calendar___Location}
    <br>Commencing on {$startDate} and finishing on {$endDate} 2019
    <br>
     
  2. startpoint

    startpoint Active Member

    Level: Community
    PHP:
    $d=strtotime("+1 Year");

    <b>Hi {$steward->FName},</b>
    <br>Your next stewarding event is {$row->calendar___Event} at {$row->calendar___Location}
    <br>Commencing on {$startDate} and finishing on {$endDate} {date("Y", $d)}
    <br>
     
  3. stevelis

    stevelis Member

    Level: Community
    Thanks Start Online and will try
    If I wanted the current year, I am assuming it would look like $d=strtotime(" Year");
    Then on the 1st Jan each year it would update itself to the current year
    Steve
     
  4. startpoint

    startpoint Active Member

    Level: Community
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Hey Steve,

    Ping me on Skype if you need more help. I think I still owe you some work on the steward emails?

    -- hugh
     
  6. stevelis

    stevelis Member

    Level: Community
    Thanks Hugh and will do
    Steve
     
  7. stevelis

    stevelis Member

    Level: Community
    Hi startpoint
    Had to go interstate for a couple days hence, a slower than normal response of thanks.
    Your reply certainly pointed me in the right direction and got the thought processes going, as I couldn't get your code to function as required.
    PHP 7.2 accepted $d = date("Y"); instead of strtotime which yielded the correct year and format, 2019
    Then I just played around with {date("Y", $d)} until it worked with $d
    <br>Commencing on {$startDate} and finishing on {$endDate} $d;
    Commencing on Sunday 21st July and finishing on Sunday 21st July 2019
    Thanks again startpoint for your assistance. :)
    Steve
     
    startpoint likes this.
  8. stevelis

    stevelis Member

    Level: Community
    Closing post as resolved
     
Thread Status:
Not open for further replies.

Share This Page