How do i set the file creation date?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gavin9822623
    New Member
    • Mar 2010
    • 2

    How do i set the file creation date?

    I need to set a file creation date to "2005/01/01 13:00:00 PM". The date format is (YYYY/MM/DD).

    Any help or example will be greatly appreciated.

    Thank you
    Gavin
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Module os has numerous functions for manipulating directories and files. In this example, I will set a file's access and modified time:
    Code:
    import os
    import time
    fn = "test.txt"
    os.utime(fn, (time.time(), 1038848567))
    Code:
    >>> import time
    >>> time.time()
    1269625312.171
    >>> time.ctime(1038848567)
    'Mon Dec 02 11:02:47 2002'
    >>>
    Check out time.strptime() for your date format.

    Comment

    • gavin9822623
      New Member
      • Mar 2010
      • 2

      #3
      Thank you very much :)

      Comment

      Working...