Created
May 15, 2021 14:56
-
-
Save thanakijwanavit/349433be66dae23f59bcf8a82c396dbc to your computer and use it in GitHub Desktop.
datestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "datestamp", | |
"private_outputs": true, | |
"provenance": [], | |
"authorship_tag": "ABX9TyPsDgE9qhvCTezGQKgZgcAJ", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/thanakijwanavit/349433be66dae23f59bcf8a82c396dbc/datestamp.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "U5HSHS42T2bD" | |
}, | |
"source": [ | |
"from datetime import datetime" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "hXe4X3rUT7VS" | |
}, | |
"source": [ | |
"# get datestamp\n", | |
"from datetime import datetime, timezone\n", | |
"dt = datetime.utcnow()\n", | |
"datetime(day=dt.day,month=dt.month,year=dt.year,tzinfo=timezone.utc).timestamp()" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "Vshl15JpUHbk" | |
}, | |
"source": [ | |
"datetime.today().timestamp()" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "z4SzOaSKVbwg" | |
}, | |
"source": [ | |
"dt" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "RgMSvStsV2RF" | |
}, | |
"source": [ | |
"datetime.fromtimestamp(1619456400)" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "m2uTiOAXYok6" | |
}, | |
"source": [ | |
"# use nichelper" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "3Di70BlQYwdt" | |
}, | |
"source": [ | |
"!pip install -q nicHelper" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "OEXeiZYPYp4E" | |
}, | |
"source": [ | |
"from nicHelper.datetime import datestamp\n", | |
"datestamp()" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "X-NGaUeOZC8h" | |
}, | |
"source": [ | |
"from nicHelper.datetime import stringToTimestamp" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "_IouLwa-e3rJ" | |
}, | |
"source": [ | |
"stringToTimestamp('04-02-90','%d-%m-%y')" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "ylYB7ZOhf-DY" | |
}, | |
"source": [ | |
"" | |
], | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment