Retrieve filedate / Time

I want to show this file:

http://www.msccrociere.it/maps/MSCDIVINA/web2.jpg

But I also want to show the date and  time (LastmodifiedTime)

Is this possible i ASP.

Thanks in advance
steltonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KimputerCommented:
Something like this should work:

System.IO.File.GetLastWriteTime(Server.MapPath("web2.jpg")).ToString("HH:mm:ss dd/MM/yyyy")

Open in new window


Please note, if that picture is NOT on your own server, it's of no use.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Yes, you can use fso (File Scripting Object) http://www.w3schools.com/asp/prop_datelastmodified_file.asp

<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFile("c:\path_to\maps\MSCDIVINAweb2.jpg")
Response.Write("File last modified on: ")
Response.Write(f.DateLastModified)
set f=nothing
set fs=nothing
%>

Output:

File last modified on: 1/10/2001 10:01:19 AM

Open in new window

steltonAuthor Commented:
The file is on an external URL, will your solutions Works with that?
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

KimputerCommented:
As I clearly said, it WILL NOT WORK. A remote server doesn't give you this information.
steltonAuthor Commented:
Sorry has not seen your note.... I understand....
KimputerCommented:
Actually, I wasn't 100% accurate. A web server _CAN_ send you the last modified date (can also be removed though), and it's a matter if you trust this info or not.
For ASP.net use the HttpRequest and then read the headers.
Classic ASP should use MSXML2.ServerXMLHTTP (again, read headers)
steltonAuthor Commented:
Okay... if I trust the info, how do I then retrieve the date / time of the file with asp code
KimputerCommented:
what ASP version are you running?
steltonAuthor Commented:
V4.0 found on the IIS server does that make sence? Else how to found out?
KimputerCommented:
This is working code:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Net" %>

<html>

<head>
<title>Get last-modified</title>
</head>
<body bgcolor="#FFFFFF">

<script language="vbscript" type="text/vbsscript" runat="server">

function getURLHeader(url)

Dim strings as WebHeaderCollection
Dim output as String
 Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
            ' Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. 
            Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
            strings = myHttpWebResponse.Headers
			output = strings.Get("Last-Modified")

	    myHttpWebResponse.Close()
		return output
  
end function

</script>


<% response.Write(getURLHeader("http://www.msccrociere.it/maps/MSCDIVINA/web2.jpg"))
%>

</body>
</html>

Open in new window

steltonAuthor Commented:
Thank you. I have tried to save the code to an asp fil, but I get a "500 - Internal server error."

The server I use is my own. Could it have something to do with the rights you are talking about. If yes could you give me a hint where to change them.. if it is this issue which are the problem.
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Using Kimputer's code, you should be saving your file as .aspx and not .asp.
steltonAuthor Commented:
Thank you that Works :-)

Now I only want to understand the time it shows:

Wed, 08 Apr 2015 06:10:02 GMT

The time at me is 08.33 (Morning) and at the ship it schould be 02.33 (Night)

I know that there will be a difference becauase of the refreshing of the webcam Picture, but how to explain the time of the Picture to 06:10:02 GMT
KimputerCommented:
GMT is greenwich mean time. Just get your time zone offset and always add or substract that offset (hopefully daylight saving won't be an issue, but otherwise, one or two months per year it will be one hour off, unless you use some more code to fix it, or have a smart time converter.
From your info, you're probably in the CEST time zone with a GMT 2+ hour difference (the returned time is in 24hr format), while the ship is in EST time (GMT -4 hour)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.