Page 1 of 3

Changing Date Format in include-NOAA-reports.php?

Posted: Tue 26 Feb 2013 7:16 pm
by William Grimsley
Hi Ken,

Is it possible, to change the date format on the line ABOVE the NOAA Report files?

e.g. from 2013 Feb to Feb 2013 or 02/2013?

I tried changing:

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $now_year ".$longmonths[$now_month]."</b>\n";
To

Code: Select all

echo "<br /><b>".langtransstr('Report for').".$longmonths[$now_month]." $now_year</b>\n";
But, the file didn't do what I THOUGHT it was going to do... :bash:

Please help,

Thanks

William

Re: Changing Date Format in incllude-NOAA-reports.php?

Posted: Wed 27 Feb 2013 12:29 am
by water01
William, don't you think it is about time you invested in a PHP course?

Randomly changing around php code and expecting people to fix it for you, especially Ken who seems to have the patience of a saint, is not on.

If you look carefully at the code lines (especially the pairing of double quotes and the positioning of the full stops) it is quite obviously why the new line of code will fail php syntax checking.

Re: Changing Date Format in incllude-NOAA-reports.php?

Posted: Wed 27 Feb 2013 7:38 am
by William Grimsley
Well, no. I'm 14, so I can't go on a PHP course...

Re: Changing Date Format in incllude-NOAA-reports.php?

Posted: Wed 27 Feb 2013 8:02 am
by water01
What has age got to do with it, my son learnt it at 11. You are on a computer, you have access to the internet, so here is a free step by step tutorial that will teach you the basics http://www.w3schools.com/php/default.asp.

Re: Changing Date Format in incllude-NOAA-reports.php?

Posted: Wed 27 Feb 2013 8:09 am
by William Grimsley
water01 wrote:What has age got to do with it, my son learnt it at 11. You are on a computer, you have access to the internet, so here is a free step by step tutorial that will teach you the basics http://www.w3schools.com/php/default.asp.
Hi David,

Ok, I'll take a look at that link, later.

What I was on about is, going to an actual PHP class. But, if I can learn it on the internet that's great! :D

Thanks for the link,

William

Re: Changing Date Format in incllude-NOAA-reports.php?

Posted: Wed 27 Feb 2013 8:54 am
by water01
There are also quite a lot of books. This one is not expensive http://www.computermanuals.co.uk/script ... motion=REC and is suitable for someone initially learning PHP and also teaches you how to interact with MySQL databases.

Re: Changing Date Format in incllude-NOAA-reports.php?

Posted: Wed 27 Feb 2013 11:00 am
by William Grimsley
Hi David,

Thanks for the book, too. I think I'll stick to the link for now.

Thanks again,

William

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Wed 27 Feb 2013 4:49 pm
by William Grimsley
Arrrrggghhhh! I can't do this! :cry: :bash:

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Wed 27 Feb 2013 7:11 pm
by RayProudfoot
William,

If you're frequently asking for help on PHP it suggests you're trying to run before you've learned to walk - or crawl. ;)

We were all novices in various skills once. You'll find it far more satisfying learning to write and change PHP than asking others for the answers.

The link provided by David looks like an excellent starting point. I want to learn PHP too once I've retired and I think a book is far preferable to an on-line course although both are useful in their own ways.

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Wed 27 Feb 2013 7:22 pm
by William Grimsley
Well, I never! I've fixed it!

I found that in the wxnoaaclimatereports.php file, it was including the NOAA-reports.php file and not the include-NOAA-reports.php file, so for a start, I was actually editing a file that wasn't even being included in the wxnoaaclimatereports.php file, in the first place! :oops:

Then, I changed the include-NOAA-reports.php file from:

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $yr "; echo isset($longmonths[$mo])?$longmonths[$mo]:''; echo "</b>\n;
To

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $months[$mo] ".$yr."</b><br />\n";
Then, the include-NOAA-reports.php file, displayed what I wanted. :D

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Thu 28 Feb 2013 5:18 am
by gemini06720
Really, William, you should take some time off of the modifications and start learning PHP... :roll:

You have modified the following line (which is really three lines of code):

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $yr "; echo isset($longmonths[$mo])?$longmonths[$mo]:''; echo "</b>\n;
to:

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $months[$mo] ".$yr."</b><br />\n";
Do you have any idea why the 'isset' function was there in the first instance!

'isset' is there to test if the array '$longmonths[$mo]' is set and is not 'null':
  • - If the array is not set (or is 'null'), then the 'echo' function will display the empty value of ''.
    - If the array is set, then the 'echo' function will display the value of the array '$longmonths[$mo]'.
So, if for any reasons one of the '$mo' (month) value is not set or contains an invalid value, then your modified line will produce a PHP error...

As 'the other' Ray suggested, you should learn to 'crawl' into PHP before continuing even further into your trend to modify (and asking over and over) for help whenever you cannot figure out what to do (or why your modifications are not producing the results you are expecting).

And age has nothing to do with learning PHP - I started learning PHP some 6+ years ago - and I was in my late 50s at that time... :geek:

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Thu 28 Feb 2013 7:34 am
by William Grimsley
gemini06720 wrote:Really, William, you should take some time off of the modifications and start learning PHP... :roll:

You have modified the following line (which is really three lines of code):

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $yr "; echo isset($longmonths[$mo])?$longmonths[$mo]:''; echo "</b>\n;
to:

Code: Select all

echo "<br /><b>".langtransstr('Report for')." $months[$mo] ".$yr."</b><br />\n";
Do you have any idea why the 'isset' function was there in the first instance!

'isset' is there to test if the array '$longmonths[$mo]' is set and is not 'null':
  • - If the array is not set (or is 'null'), then the 'echo' function will display the empty value of ''.
    - If the array is set, then the 'echo' function will display the value of the array '$longmonths[$mo]'.
So, if for any reasons one of the '$mo' (month) value is not set or contains an invalid value, then your modified line will produce a PHP error...

As 'the other' Ray suggested, you should learn to 'crawl' into PHP before continuing even further into your trend to modify (and asking over and over) for help whenever you cannot figure out what to do (or why your modifications are not producing the results you are expecting).

And age has nothing to do with learning PHP - I started learning PHP some 6+ years ago - and I was in my late 50s at that time... :geek:
Oh, dear. Didn't you realise that it actually works in the first instance? :oops:

A PHP Error? http://validator.w3.org/check?uri=http% ... orts%2ephp

I am learning PHP, now. That's how I've managed to do what I've done, because I know how it works! ;)

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Thu 28 Feb 2013 8:51 am
by water01
William, you haven't read what Ray said!!!! Of course the php will validate but in the circumstances when the month is not set or contains an invalid value the php will generate incorrect code and it will fail.

PHP validation cannot by it's very nature test all circumstances that could occur when testing is made on data, it can only test syntax as it exists with code submitted at validation.

So at some stage in the future if the condition you removed exists your code will fail.

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Thu 28 Feb 2013 9:08 am
by gemini06720
William Grimsley wrote:Oh, dear. Didn't you realise that it actually works in the first instance?
You are indeed a very obnoxious young man - you need to do a lot of growing up! :evil:

The fact that the page passed the W3C Markup Validation Service means nothing other than the HTML code being sent to the Markup Validation Service meets the W3C standards.

PHP is not checked by the W3C Markup Validation Service - PHP cannot be checked by the W3C Markup Validation Service - PHP is a server-side scripting language - meaning ... the PHP code must first be 'interpreted' by PHP processor module on the Web server before generating the resulting Web page - for your PHP education you might want to have a look at the Wikipedia 'PHP' page (you do know how to read?). :roll:
That's how I've managed to do what I've done, because I know how it works!
You do - do you?!?! :o

If you really knew how PHP work you would not ask all those stupid questions you have been asking after making some modifications to the code ... if you really knew how PHP works, then you would have made no coding error ... you would have no need to ask for assistance ... you would already have all the answers for as all the requests you have made so far... :shock:

Re: Changing Date Format in include-NOAA-reports.php?

Posted: Thu 28 Feb 2013 11:03 am
by William Grimsley
Ok, sorry. I'm confused. :oops: