Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to output date created and date modified?
#2
the reason your output is the same is your using the same variable for both created and modified

this is more what your after
Code:
Copy      Help
DateTime tc tm
FileGetAttributes("$desktop$\test\1.jpg" 0 tm tc); err out _error.description; ret
tm.UtcToLocal; tc.UtcToLocal;str stm=tm.ToStr(4);str stc=tc.ToStr(4)
out "created=%s modified=%s" stc stm

on another note if the image has metadata you can get the actual date and time the image was taken using thisĀ 

Function GetDateTaken
Code:
Copy      Help
str path.expandpath("$desktop$\test\1.jpg")
str R=CsFunc("" path)
if(R !="No MetaData found")
,DateTime dt
,ARRAY(str) arr
,int i nt
,nt=tok(R arr -1 " ")
,_s=arr[0]
,_s.findreplace(":" "/")
,_s+ F" {arr[1]}"
,dt.FromStr(_s)
,out dt.ToStr
else
,out R
#ret
using System;
using System.Drawing.Imaging;
using System.Drawing;
using System.Text;
public class Example
{
,public static string StaticFunc(string s)
,{
,,// Add reference => Assemblies => Framework => System.Drawing
;;;;;;;;// Set the path to your photo file.
,,var path = @s;
,,var image = new Bitmap(path);
;;;;;;;;// Get PropertyItems
,,var propItems = image.PropertyItems;
;;;;;;;// Remove encoding object
,,var encodings = new ASCIIEncoding();
,,string datetime = "";
;;;;;;;// Display
,,int count = 0;
,,foreach (var propItem in propItems)
,,{
,,,// The values below come from http://msdn.microsoft.com/en-us/library/xddt0dz7(v=vs.110).aspx
;;;;;;;;;;;;// Find al values available with Console.WriteLine(propItem.Id.ToString("x"));
,,,if (propItem.Id.ToString("x").Equals("9003")) //ExifDTOriginal
,,,{
,,,,count = 1;
,,,,datetime = encodings.GetString(propItem.Value);
,,,}
,,}
,,if (count == 0)
,,{
,,,return "No MetaData found";
,,}
,,else
,,{
,,,return datetime;
,,}
,}
}


Messages In This Thread
RE: How to output date created and date modified? - by Kevin - 08-03-2019, 03:46 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)