if (!is_dir($lat . ',' . $long)) {
    mkdir($lat . ',' . $long);
}
if (!is_dir($lat . ',' . $long . '/Forecast Data')) {
    mkdir($lat . ',' . $long . '/Forecast Data');
}
if (!is_dir($lat . ',' . $long . '/Forecast Data/' . $year)) {
    mkdir($lat . ',' . $long . '/Forecast Data/' . $year);
}
if (!is_dir($lat . ',' . $long . '/Forecast Data/' . $year . '/' . $month)) {
    mkdir($lat . ',' . $long . '/Forecast Data/' . $year . '/' . $month);
}
if (!is_dir($lat . ',' . $long . '/Forecast Data/' . $year . '/' . $month . '/' . $date)) {
    mkdir($lat . ',' . $long . '/Forecast Data/' . $year . '/' . $month . '/' . $date);
}
Find_Weather_Station($lat, $long);
/* 
 * Finding the local timezone based on lat & long
 */
function Find_Local_Timezone($lat, $long)
{
    global $date, $year, $month;
    $URL = 'https://maps.googleapis.com/maps/api/timezone/json?location=' . $lat . ',' . $long . '&timestamp=' . strtotime(Date('d-m-Y'));
    $jsonResult = file_get_contents($URL);
    $result = json_decode($jsonResult, true);
    $timeZone_Id = $result['timeZoneId'];
    date_default_timezone_set($timeZone_Id);
    $date = Date('d-m-Y');
    $year = Date('Y');
    $month = Date('F');
}
}
if (!is_dir($lat . ',' . $long . '/Historical Data')) {
    mkdir($lat . ',' . $long . '/Historical Data');
}
/* 
 * Generating the past years based on the current year and the no. of past year provided
 */
while ($Count_year <= $No_Past_year) {
    $Year = Date('Y', strtotime('-' . $Count_year . 'year'));
    array_push($Past_year, $Year);
    if (!is_dir($lat . ',' . $long . '/Historical Data/' . $Year)) {
        mkdir($lat . ',' . $long . '/Historical Data/' . $Year);
    }
    $Count_year++;
}
Find_Weather_Station($lat, $long, $Past_year);
/* 
 * Finding the local timezone based on lat & long
 */
function Find_Local_Timezone($lat, $long)
{
    global $date;
    $URL = 'https://maps.googleapis.com/maps/api/timezone/json?location=' . $lat . ',' . $long . '&timestamp=' . strtotime(Date('d-m-Y'));
    $jsonResult = file_get_contents($URL);
    $result = json_decode($jsonResult, true);
    $timeZone_Id = $result['timeZoneId'];
    return $timeZone_Id;
}
/* 
 * Finding the closest weather station based on lat & long
 */