Hello Peppe757,

I've found another discussion regards this topic here. In this article there is an interesting link to Windows file times.

So as it seems ctime does not give what you want.

In the 'Windows file times' link the function GetFileTime is mentioned so looking for that I found the module Win32API::File::Time that has this function. So maybe you can try to use that one instead.

edit: I found another module that I actually like better. The module is called Win32::UTCFileTime. I have created the following sample program for testing:

use strict ; use warnings ; use DateTime ; use Win32::UTCFileTime qw(alt_stat $ErrStr) ; my $file = ".\\testFileTime2.pl" ; my @stats = alt_stat( $file ) or die "alt_stat() failed: $ErrStr\n" ; print "ctime = $stats[10]\n" ; my $dt = DateTime->from_epoch( epoch => $stats[10], time_zone => 'UTC' + ) ; print $dt->datetime . "\n" ; __END__ ctime = 1530825924 2018-07-05T21:25:24

edit 2: Anonymous Monk asked: "But is it any different from built-in stat". The answer can be found in the documentation: Note that the 11th element of the 13-element list returned by stat() is the creation time on Win32, not the inode change time as it is on many other operating systems. Therefore, neither Perl's built-in utime() function nor this replacement function set that value to the current time as would happen on other operating systems.


In reply to Re: Getting the correct ctime for a file on Windows 10 by Veltro
in thread Getting the correct ctime for a file on Windows 10 by Peppe757

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.