Find Out What Happened On This Day PHP Script Using Hiztory API

Hello Programmers, Today  In this Tutorial, I am gonna show you a cool PHP Code to show what happened on this day using Hiztory API.

To understand this tutorial you should have basic knowledge on How to Parse XML Data in PHP

How To Add Watermark in Images Using PHP – Source Code

I think all of you visits google at least once a day and all of you have seen that on special day’s google’s logo gets replaced by some other images or animations.

Okay, that is what happened on this day feature. Even some calendar applications use this feature.
Today I will provide you a PHP code where I will parse XML data to show what happened on this day. This is pretty interesting as it will show you all the special events that have been occurred in the history before.

So our main aim is to get the data and it is our good luck that there are some API providers who are providing the data via XML file.

In this tutorial, I will use the API of .

What Happened On This Day PHP Program with an XML API

You Can download this Script for free from our GitHub Link below provided,


This PHP program will display some special events occurred on the same day in the history.

So here is the code

<!DOCTYPE html>
  <title>On This Day</title>


   $xml = simplexml_load_file($url);
   foreach ($xml->events as $events) {
   		 	foreach ($events->event as $event) {

   		echo "$i"."."." ";
   		echo $event['content'].' '.'<br>';





This will display the first 15 number of events of today’s date.

URL Pattern of XML file:

08 is the month, must have two digits.
27 is the date also must have two digits. If the date is of 1 digit then we have two use zero as the prefix.
1 is the number of pages. Below XML file contains page number tag.
15 is limit for the events on a single page.



Movie Video Trailers And Info PHP Script That Uses TMDB API

This is a date function and m/d is for our date format which follows the Hiztory API URL format for date.

$url is for the URL string. Here we joined $today in the URL pattern to match the API URL Pattern.

$i is used just to show the serial number of the events.

PHP Weather Forecast Script That Uses OpenWeatherMap API

And the XML File looks like this:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<status code="200" message="OK"/>
<page number="1" limit="15" results="28" totalpages="2"/>
<event date="2011-09-26" content="Boeing delivers its first Boeing 787 Dreamliner to a customer, All Nippon Airways, at Paine Field in Washington"/>
<event date="2008-09-26" content="Yves Rossy, Swiss airline pilot and former fighter pilot, crosses the English Channel with his homemade jet-powered wing strapped on his back."/>
<event date="2002-09-26" content="Air Canada Douglas DC-9 makes final flight to place of honour at the Canada Aviation Museum"/>
<event date="1997-09-26" content="Garuda Indonesia Flight 152, an Airbus A300, crashes into a mountain near Buah Nabar, Indonesia, killing all 234 on board."/>
<event date="1993-09-26" content="Launch: Spot-3 satellite. Stopped functioning November 14, 1997."/>
<event date="1986-09-26" content="First flight of the Piaggio Avanti"/>
<event date="1983-09-26" content="Cosmonauts Titov and Strekalov are saved from exploding Soyuz T-10."/>
<event date="1981-09-26" content="First flight of the Boeing 767-200"/>
<event date="1981-09-26" content="Vietnamese Cosmonaut Bui Thanh Liem (June 30, 1949–September 26, 1981), a native of Hanoi, Vietnam, is killed in a training flight in a Mikoyan-Gurevich MiG-21 over the Gulf of Tonkin this date."/>
<event date="1980-09-26" content="First flight of the Shanghai Y-10"/>
<event date="1977-09-26" content="Laker Airways inaugurates its no-booking &quot;Skytrain&quot; service between London and New York"/>
<event date="1976-09-26" content="A USAF Boeing KC-135A-BN Stratotanker, 61-0296, c/n 18203, of the 46th Air Refueling Squadron, Strategic Air Command, on a routine tanker training mission en route from K.I. Sawyer AFB, Michigan, to Offutt AFB, Nebraska (two sources list Wurtsmith AFB, Michigan as its destination), crashes at 0830 hrs. EDT in a densely wooded swampy area near Alpena, Michigan, killing 15 of the 20 on board. Possible cabin pressurization problem may have led to the accident."/>
<event date="1974-09-26" content="The first CF C-130 H was delivered to the RCAF 435 Squadron."/>
<event date="1973-09-26" content="The Concorde makes its first non-stop crossing of the Atlantic in record-breaking time, though the record would go on to be broken a few more times until the aircraft’s retirement in 2003."/>
<event date="1967-09-26" content="The governments of France, West Germany, and Britain sign a memorandum that calls for the development of the Airbus A300 wide-bodied jet airliner."/>

So you can see that parent node is <aviation>

Under <aviation> child node is <eventes>

and in this event section, we have the event with date tag and content tag which we have parsed using the above PHP code.

Movie Video Trailers And Info PHP Script That Uses TMDB API

Leave a Reply

Your email address will not be published. Required fields are marked *