A function to get a Timestamp string in the format YYYY_MM_DD_HH_MM_SS_microseconds ('_' can be defined)
Project description
A function to get a Timestamp string in the format YYYY_MM_DD_HH_MM_SS_microseconds ('_' can be defined)
pip install gettimestamp
Tested against Windows 10 / Python 3.10 / Anaconda
The function takes an optional sep argument, which represents the separator character used in the timestamp string. By default, the separator is set to "_".
The function utilizes the datetime module to retrieve the current date and time. It formats the timestamp using the provided separator and includes the year, month, day, hour, minute, second, and microseconds.
The resulting timestamp string is returned by the function. However, if the separator is set to "ÇÇÇÇSXÇX", a ValueError is raised to prevent the use of that specific separator.
Args:
sep (str, optional): Separator character to use in the timestamp string. Defaults to "_".
Returns:
str: Timestamp string in the format "YYYY_MM_DD_HH_MM_SS_microseconds".
Raises:
ValueError: Raised when the separator is set to "ÇÇÇÇSXÇX".
Example:
from gettimestamp import get_timestamp
>>> get_timestamp()
'2023_06_26_15_30_45_123456'
>>> get_timestamp("-")
'2023-06-26-15-30-45-123456'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gettimestamp-0.11.tar.gz
.
File metadata
- Download URL: gettimestamp-0.11.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc2d590e501d8f796566d3b5df2e234d59535b7a75a5cf59903d301422f3cce |
|
MD5 | 6bde8a109b3872f823ba0ee5bd834210 |
|
BLAKE2b-256 | 0c634bd78844b267be237671e98cb19bf34afbee8211c986c5a4609eb69d33f7 |
File details
Details for the file gettimestamp-0.11-py3-none-any.whl
.
File metadata
- Download URL: gettimestamp-0.11-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac1775be5bee29e87c9fa3de1e6fb000a0ffaa15f35f67231f7b873b30bcdead |
|
MD5 | 7d95a4b13b6184f4a20bbd991e19ed3a |
|
BLAKE2b-256 | 514819fc67b88a77e1857ea291124cad7dc484d525372b9856abfcd6362cbed8 |