Python Forum
Timestamp of file changes if a share mapped to a server….
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timestamp of file changes if a share mapped to a server….
#6
As I said, the timestamps are UTC (I said GMT earlier, but they are the same) and when displayed will be corrected for the timezone you are in. A file changed in Kuala Lampur will have a timestamp 15 hours older when viewed from a computer in Kuala Lampur than the same file viewed from Seattle. You can verify this by changing the timezone for your computer. Instantly the timestamps will agree.

I think the problem may be that you are being naive. Read the section about Aware vs Naive.

https://docs.python.org/3/library/datetime.html

You might also find this interesting.

https://howchoo.com/g/ywi5m2vkodk/workin...-in-python

Here's an example of using "aware" datetime objects.
import pytz
import os

x = os.path.getctime("input.txt")
koala_lampur = datetime.fromtimestamp(x, tz=pytz.timezone('Asia/Kuala_Lumpur'))
seattle = datetime.fromtimestamp(x, tz=pytz.timezone('US/Pacific'))
here = datetime.fromtimestamp(x)

print("Koala Lampur", koala_lampur)
print("Seattle", seattle)
print("US Central", here)
print(koala_lampur == seattle, koala_lampur == here, seattle == here)
Output:
Koala Lampur 2023-02-14 10:59:15.117121+08:00 Seattle 2023-02-13 18:59:15.117121-08:00 US Central 2023-02-13 20:59:15.117121 True False False
Even though Seattle and Koala Lampur datetime strings are 15 hours apart, Python returns True when asked if they are equal. The naive "here" datetime object displays a correct US/Central time, but is not appropriate for comparing against datetime objects from different time zones.
tester_V likes this post
Reply


Messages In This Thread
RE: Timestamp of file changes if a share mapped to a server…. - by deanhystad - Jun-23-2023, 09:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 376 May-03-2024, 07:23 AM
Last Post: Pedroski55
  Trying to access excel file on our sharepoint server but getting errors cubangt 0 889 Feb-16-2023, 08:11 PM
Last Post: cubangt
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,288 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  error in timestamp Led_Zeppelin 3 3,384 Jun-15-2022, 08:28 PM
Last Post: deanhystad
  error in timestamp Led_Zeppelin 0 1,070 Jun-10-2022, 07:59 PM
Last Post: Led_Zeppelin
  access share attributed among several class methods drSlump 0 1,119 Nov-18-2021, 03:02 PM
Last Post: drSlump
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,614 Oct-21-2021, 03:29 AM
Last Post: buran
  How to take the tar backup files form remote server to local server sivareddy 0 1,988 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,564 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  How to share a numpy array between 2 processes on Windows? qstdy 0 2,214 Jan-29-2021, 04:24 AM
Last Post: qstdy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020