Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

PHP question

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
Mapantz
Posts: 1808
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

PHP question

Post by Mapantz »

I am not really great at this stuff and only know a few basics, so this has me stumped..

Is there any reason why the below code doesn't work, but entering the numbers manually does?

Code: Select all

$previousDay   	=    '<?php echo date("Y"); ?>'.'-';
$previousDay   	.=   '<?php echo date("m"); ?>';
$previousDay   	.=   '-'.'<?php echo date("d"); ?>';

Code: Select all

$previousDay   	=    '2019'.'-';
$previousDay   	.=   '11';
$previousDay   	.=   '-'.'26';
Many thanks!
Image
User avatar
saratogaWX
Posts: 1185
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: PHP question

Post by saratogaWX »

That is a bit of odd code..
Some things to keep in mind:
1) string literals inside single-quoted strings aren't evaluated by PHP. Only string literals within double quoted strings are evaluated.
2) there's a much simpler way to ensure your $previousDay variable inside PHP is set with the date of yesterday:

Code: Select all

$previousDay = date("Y-m-d",strtotime("yesterday"));
Mapantz
Posts: 1808
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: PHP question

Post by Mapantz »

Wow yeah, that does simplify what I was trying to achieve.

Many thanks, Ken. Much appreciated! :)
Image
Post Reply