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….
#31
(Jul-02-2023, 10:59 PM)tester_V Wrote: ok. I'm staying with the UTC timestamp. UTC timestamp has no time zone.
Then why are you adding a timezone,just add 24 hour to timestamp if that 's what you need.
from datetime import datetime, timedelta

# They make this timestamp in Kuala_Lumpur
timestamp = datetime.now().timestamp()

# On your side add 24 hour
to_date = datetime.fromtimestamp(timestamp)
add_24 = to_date + timedelta(hours=24)
print(to_date)
print(add_24)
Output:
2023-07-03 12:21:18.615738 2023-07-04 12:21:18.615738
Reply
#32
(Jul-03-2023, 10:09 AM)snippsat Wrote: Then why are you adding a timezone,just add 24 hour to timestamp if that 's what you need.
From the OP, the goal is to find files that have a modification time that falls in some window (yesterday's timestamps). If you set the start time to now() and add 24 hours to get the end, you are looking in the future and no files will match the query.

If yesterday is yesterday in Kuala Lumpur, there could be files that were modified "today", so you need a start and end timestamp. In that case I would set the start time to "yesterday" and the end time to "today" using the Kuala Lumpur timezone (Asia/Kuala_Lumpur). I mentioned this in an earlier post. My thought was to create a DateTime object using today's date, time=0, and timezone=Kuala Lumpur, but I think snippsat is correct about using pendulum. Using pendulum this is all you need to get start and stop timestamps to find files that were modified yesterday in Kuala Lumpur.
tz = 'Asia/Kuala_Lumpur'
start_time = pendulum.yesterday(tz=tz).timestamp()
end_time = pendulum.today(tz=tz).timestamp()
So, what do you want tester? You've been pretty vague in all your descriptions. Does "yesterdays timestamps" start with yesterday() (yesterdays date, time = 00:00.00) and end with today() (todays date, time = 00:00.00). If so, for what time zone?

And there is still the question of daylight savings time. If you are using a local time, there will be gaps/overlaps in consecutive time windows when daylight savings time starts/ends. Does this matter?
tester_V likes this post
Reply
#33
I finally I got it and it is thank you guys, thank you!
Love you all, you guys are great!
may forth be with you! Wink
Happy holiday!
Tester_v.
Reply
#34
tester_V Wrote:may forth be with you!
as in Charles Moore forth?
If so, forth is one of the best languages ever written for scientific work.
tester_V likes this post
Reply
#35
That is why people come to this forum, it has a good vibe, great people, and attitude.
You see, I learned something new to me again for free! Wink

Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to access excel file on our sharepoint server but getting errors cubangt 0 825 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,233 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  error in timestamp Led_Zeppelin 3 3,245 Jun-15-2022, 08:28 PM
Last Post: deanhystad
  error in timestamp Led_Zeppelin 0 1,016 Jun-10-2022, 07:59 PM
Last Post: Led_Zeppelin
  access share attributed among several class methods drSlump 0 1,072 Nov-18-2021, 03:02 PM
Last Post: drSlump
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,502 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,917 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,486 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  How to share a numpy array between 2 processes on Windows? qstdy 0 2,171 Jan-29-2021, 04:24 AM
Last Post: qstdy
  Access Network SMB Share on a NAS deltapy 2 9,075 Oct-31-2020, 09:14 AM
Last Post: deltapy

Forum Jump:

User Panel Messages

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