Welcome! Log In Create A New Profile

Advanced

[PHP] Something is wrong with "date" => 1970

Posted by Michelle Konzack 
Michelle Konzack
[PHP] Something is wrong with "date" => 1970
September 16, 2017 12:50PM
Hello *,

the code sniplet is:

----[ 'energy_harvesting.php' ]-----------------------------------------

$LIST=shell_exec('ls /srv/CONFIG_www.miila-mahe-aed.eu/htdocs/renewable_energies/data/20*.data |sort');

$ARRAY=preg_split('/\s+/', $LIST, -1, PREG_SPLIT_NO_EMPTY);

$TITLE = "";

foreach ( $ARRAY AS $DAY) {
include $DAY;
$NEW_TITLE = date('Y', $date);

if ( $NEW_TITLE != $TITLE ) {
echo '<TABLE class="table_energy">';
echo '<TR class="table_energy_row">';
echo ' <TD class="energytable_title" colspan="6"><SPAN class="comments">' . $NEW_TITLE . '</SPAN></TD>';
echo '</TR>';
echo '<TR class="table_energy_row">';
echo ' <TD class="energytable_num" ><SPAN class="comments">No</SPAN></TD>';
echo ' <TD class="energytable_date" ><SPAN class="comments">Date</SPAN></TD>';
echo ' <TD class="energytable_time" ><SPAN class="comments">Time</SPAN></TD>';
echo ' <TD class="energytable_wh_solar"><SPAN class="comments">Wh Solar</SPAN></TD>';
echo ' <TD class="energytable_wh_wind" ><SPAN class="comments">Wh Wind</SPAN></TD>';
echo ' <TD class="energytable_comment" ><SPAN class="comments">Comments</SPAN></TD>';
echo '</TR>';
$TITLE = $NEW_TITLE;
}

echo "<PRE>";
echo $DAY . "</P>";
echo $date . "</P>";
echo $NEW_TITLE . "</P>";
echo "</PRE>";
}
------------------------------------------------------------------------

it does not work as expected.

$DAY is corect the filename.
$date is a value inside the (php) file and is correct e.g. 2017-08-31

However, $NEW_TITLE is not working and show always "1970 January"

Where is my thinking error?

Does date() not more accept an ISO Date of 2017-08-31?

I had already used it and it was working properly.

Thanks in avance

--
Michelle Konzack Miila ITSystems @ TDnet
GNU/Linux Developer 00372-54541400
Michelle Konzack
[PHP] Re: Something is wrong with "date" => 1970
September 16, 2017 12:50PM
Grmpf!

forgotten the strtotime().

--
Michelle Konzack Miila ITSystems @ TDnet
GNU/Linux Developer 00372-54541400
Sorry, only registered users may post in this forum.

Click here to login