Convert time zone after fetching time of a remote file

Purpose: To get time zone of a remote file in my time zone. I have to download a file daily (mp3, don’t worry its legal!) from BBC. Problem is that sometimes BBC doesn’t update the file and i have to download entire file to check if it has been updated or not. Hence i decided to code a page that gives me date and time of that remote file. I have successfully compiled the code (that i got from internet). But the time returns in EST. I want the time in IST (indian std time Asia/Calcutta). CURLINFO_FILETIME has bee used. Below is code.

Pls suggest me how to convert EST to IST
Warning: I am n00b
But not f00l. :slight_smile:

[php]<?php
$curl = curl_init(‘http://wsdownload.bbc.co.uk/hindi/tx/32mp3/din_bhar.mp3’);

//don’t fetch the actual page, you only want headers
curl_setopt($curl, CURLOPT_NOBODY, true);

//stop it from outputting stuff to stdout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// attempt to retrieve the modification date
curl_setopt($curl, CURLOPT_FILETIME, true);

$result = curl_exec($curl);

if ($result === false) {
die (curl_error($curl));
}

$timestamp = curl_getinfo($curl, CURLINFO_FILETIME);
if ($timestamp != -1) { //otherwise unknown
echo “BBC Hindi was last modified” . date(“d-m-Y h:i:s A T”, $timestamp); //etc
} ?>[/php]

I have used it with custom getRemoteFileSize function here:-

http://island.web44.net/bbc.php

you can create a function IST_from_EST like i have coded below and add or subtract the time difference of time zone and convert the time according to your need

<?php $curl = curl_init('http://wsdownload.bbc.co.uk/hindi/tx/32mp3/din_bhar.mp3'); //don't fetch the actual page, you only want headers curl_setopt($curl, CURLOPT_NOBODY, true); //stop it from outputting stuff to stdout curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // attempt to retrieve the modification date curl_setopt($curl, CURLOPT_FILETIME, true); $result = curl_exec($curl); if ($result === false) { die (curl_error($curl)); } $timestamp = curl_getinfo($curl, CURLINFO_FILETIME); if ($timestamp != -1) { //otherwise unknown echo "BBC Hindi was last modified" . date("d-m-Y h:i:s A T", $timestamp) . "
"; //etc $getdate = date("d-m-Y h:i:s A T", $timestamp); echo IST_from_EST("d-m-Y h:i:s A T",$getdate); } function IST_from_EST($required_format,$EST_val="now") { echo $EST_val."
"; return date($required_format,strtotime($EST_val." 10 Hours 30 minutes")); } ?>

Thank you so much. @Sarthak Patel
I think thats what i wanted.

Sponsor our Newsletter | Privacy Policy | Terms of Service