Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.6.5 (build 3081) - 28 May 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

See the Wiki to download the software or click on the Downloads link in the Forum Banner.

PHP question

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

Moderator: daj

Post Reply
Mapantz
Posts: 716
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 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: 1031
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: 716
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 10 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