I am taking my first attempt at writing a function within PHP.
Been reading and reviewing info on them. Here is a question I cannot find answered.
I have some code that determines days, hours, minutes and seconds for totalnumber of seconds.
My page will display days, hours, minutes and seconds for the current week, month and year.
So based on the value of $totalsecs being sent to the function
(I plan to create, this seems like good use for one?)
for week, then month, then year... I need to return the values appropriately WITHOUT overwriting the previous.
For example I send $totalsecs of 147132 for the week.
My code returns 1 day, 16 hours, 52 minutes and 12 seconds.
Next I send $totalsecs of 547132 for the MONTH and my code returns 6 days, 7 hours, 58 min and 52 seconds.
I don't want to update the previous $variables that were set for week.
Do I handle this by simply including an IF statement and checking to determine if processing WEEK, MONTH or YEAR and have different variable names for each based on these?
This seems like a good scenario for a function, just not sure if I am on the right track???
Appreciate the insight!
Sincerely,
Gary