So I'm new to PHP and write bad code. I am trying to format a calendar to show the entries as list entries. Furthermore, if an event time was entered at 12 AM, I am trying to hide that outputted value. Here is the tutorial that I am using https://spunmonkey.com/display-contents-google-calendar-php/.
Here is the code that is from the tutorial:
$eventdate = new DateTime($eventDateStr,$timezone);
$newmonth = $eventdate->format("M");
$newday = $eventdate->format("j");
$newtime = $eventdate->format("g");
$newtimeAM = $eventdate->format("A");
Here is what I am trying to do and my horribly written code (this if for the newtime div:
<?php
if ( $newtime="12" && $newtimeAM="AM") {
echo $eventdate->format("");
} else {
echo $newtime;
}
?>
I have written the same if statement for $newtimeAM. My questions are:
- Can I use the if statement to set the value to the outputted string, (like $newtime="12")?
- Can I use the format parameter to return an empty string, as to hide the values if the conditions are met?
Right now, it does display the calendar entry, but not with the time. For example, there is an entry that starts at 2 PM that I want the calendar to show, but it's not showing. Also, what references that anyone give to learn PHP online? I know w3 is pretty awesome and well as php.net.