10 examples of 'pandas timestamp to string' in Python

Every line of 'pandas timestamp to string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
117def timestamp_to_str(timestamp):
118 """Convert epoch timestamp to a time string in UTC.
119
120 Args:
121 timestamp: The epoch time, in seconds, to convert.
122 Returns:
123 String representation of the timestamp in UTC timezone.
124 """
125 if not timestamp:
126 return ''
127 if timestamp == sys.maxint:
128 # sys.maxint represents infinity.
129 return 'inf'
130 utc = pytz.timezone('UTC')
131 return datetime.datetime.fromtimestamp(timestamp, tz=utc).strftime(
132 '%Y-%m-%d %H:%M:%S %Z')
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

47def timestamp_str(timestamp):
48 return timestamp.isoformat() if timestamp else None
11def timestamp_to_SQLstring(timestamp):
12 return str(timestamp)[:-6]
42def timeStamp(dt=None, format='%Y-%m-%d_%H%M%S'):
43 if dt is None:
44 dt = datetime.now()
45 return dt.strftime(format)
43def timestampToString(value):
44 return asctime(time.gmtime(max(0, value + epoch_diff)))
9def _fmt(timestamp):
10 return timestamp.strftime('%Y-%m-%dT%H%M%S.%f')
30def converter(df: DataFrame) -> Series:
31 return df[field_name]
7def timestamp_to_datetime(s):
8 """
9 Convert a Core Data timestamp to a datetime. They're all a float of seconds since 1 Jan 2001. We calculate
10 the seconds in offset.
11 """
12 if not s:
13 return None
14
15 OFFSET = (datetime.datetime(2001, 1, 1, 0, 0, 0) - datetime.datetime.fromtimestamp(0)).total_seconds()
16 return datetime.datetime.fromtimestamp(s + OFFSET)
14def datetimeAsTimestamp(dt):
15 return dt.timestamp()
132def epoch2UTCstr(timestamp=False, fmat="%Y-%m-%d %H:%M:%S"):
133 """
134 - takes epoch timestamp
135 - returns UTC formated string
136 """
137 if not timestamp:
138 timestamp = time()
139 return strftime(fmat, gmtime(timestamp))

Related snippets