Python Forum
[SOLVED] Epoch timestamp without milliseconds?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Epoch timestamp without milliseconds?
#1
Hello,

What's a good way to get an Epoch timestamp without the milliseconds?

for row in cur.execute("SELECT id,created,title FROM content"):
	#2004-08-18 19:11:13
	formated_date = datetime.strptime(row["created"],"%Y-%m-%d %H:%M:%S")

	epoch = datetime.timestamp(formated_date)
	#BAD epoch = datetime.datetime.timestamp(formated_date).replace(microsecond = 0)
	
	#2004-08-20 13:15:42 1093000542.0 Some title
	print(row["created"], epoch, row["title"])
Thank you.
Reply


Messages In This Thread
[SOLVED] Epoch timestamp without milliseconds? - by Winfried - Jan-27-2023, 03:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] Alternative to regex to extract date from whole timestamp? Winfried 6 1,905 Nov-16-2022, 01:49 PM
Last Post: carecavoador
  error in timestamp Led_Zeppelin 3 3,318 Jun-15-2022, 08:28 PM
Last Post: deanhystad
  error in timestamp Led_Zeppelin 0 1,034 Jun-10-2022, 07:59 PM
Last Post: Led_Zeppelin
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,570 Oct-21-2021, 03:29 AM
Last Post: buran
  Stumped by my own code (ratio & epoch-time calculation). MvGulik 2 2,187 Dec-30-2020, 12:04 AM
Last Post: MvGulik
Thumbs Up Convert ActiveDirectory timestamp into regular one. Arrow (solved) SpongeB0B 2 1,991 Nov-02-2020, 08:34 AM
Last Post: bowlofred
  Writing a function to calculate time range in Unix Epoch Time t4keheart 2 3,071 Jul-15-2020, 01:55 AM
Last Post: t4keheart
  The following script works but I need to take it one step further to milliseconds. yeto 1 2,059 Jul-19-2019, 04:15 AM
Last Post: micseydel
  Parse Binary Data File and convert Epoch Time drdevereaux 1 3,254 May-16-2019, 01:56 AM
Last Post: Larz60+
  Timestamp is undefined ErnestTBass 7 8,075 Feb-16-2019, 08:27 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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