On this page
sqlite3.Timestamp
Prev: sqlite3.TimeFromTicks | Up: sqlite3 | Next: sqlite3.TimestampFromTicks
Rel: sqlite3.adapt, sqlite3.Binary, sqlite3.Blob, sqlite3.complete_statement
Ref: docs.python.org — sqlite3.Timestamp
Tags: #public #python3 #stdlib #sqlite3
Import
import sqlite3
from sqlite3 import Timestamp
Signature & Overview
sqlite3.Timestamp(...)
The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
Methods & Attributes
Timestamp.astimezone(...)— tz -> convert to local time in new timezone tzTimestamp.combine(...)— date, time -> datetime with same date and time fieldsTimestamp.ctime(self, /)— Return ctime() style string.Timestamp.date(self, /)— Return date object with same year, month and day.Timestamp.dst(self, /)— Return self.tzinfo.dst(self).Timestamp.fromisocalendar(...)— int, int, int -> Construct a date from the ISO year, week number and weekday.Timestamp.fromisoformat(object, /)— string -> datetime from a string in most ISO 8601 formatsTimestamp.fromordinal(...)— int -> date corresponding to a proleptic Gregorian ordinal.Timestamp.fromtimestamp(...)— timestamp[, tz] -> tz's local time from POSIX timestamp.Timestamp.isocalendar(self, /)— Return a named tuple containing ISO year, week number, and weekday.Timestamp.isoformat(...)— [sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].Timestamp.isoweekday(self, /)— Return the day of the week represented by the date.Timestamp.now(tz=None)— Returns new datetime object representing current time local to tz.Timestamp.replace(...)— Return datetime with new specified fields.Timestamp.strftime(...)— format -> strftime() style string.Timestamp.strptime(...)— string, format -> new datetime parsed from a string (like time.strptime()).Timestamp.time(self, /)— Return time object with same time but with tzinfo=None.Timestamp.timestamp(self, /)— Return POSIX timestamp as float.Timestamp.timetuple(self, /)— Return time tuple, compatible with time.localtime().Timestamp.timetz(self, /)— Return time object with same time and tzinfo.Timestamp.today()— Current date or datetime: same as self.class.fromtimestamp(time.time()).Timestamp.toordinal(self, /)— Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.Timestamp.tzname(self, /)— Return self.tzinfo.tzname(self).Timestamp.utcfromtimestamp(...)— Construct a naive UTC datetime from a POSIX timestamp.Timestamp.utcnow()— Return a new datetime representing UTC day and time.Timestamp.utcoffset(self, /)— Return self.tzinfo.utcoffset(self).Timestamp.utctimetuple(self, /)— Return UTC time tuple, compatible with time.localtime().Timestamp.weekday(self, /)— Return the day of the week represented by the date.
Usage
import datetime
import sqlite3
ts = sqlite3.Timestamp(2026, 12, 2, 17, 30, 0)
assert ts == datetime.datetime(2026, 12, 2, 17, 30, 0)
Gotchas
- DB-API 2.0 alias for
datetime.datetime: Preferdatetime.datetime(stored as ISO-8601 text or Unix epoch integers).
REPL Inspect
from sqlite3 import Timestamp
help(Timestamp)
Linked from
Related notes
- tuts/python3/stdlib_module/sqlite3 Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/TimeFromTicks Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/TimestampFromTicks Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/adapt Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Binary Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/Blob Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/sqlite3/complete_statement Linked here; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib