Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Last active April 27, 2021 03:39
Show Gist options
  • Save thanakijwanavit/1f1783bd251d01dfbb0318b423358299 to your computer and use it in GitHub Desktop.
Save thanakijwanavit/1f1783bd251d01dfbb0318b423358299 to your computer and use it in GitHub Desktop.
datestamp
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "datestamp",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyOdaes/7yhlYmiHG97loYNz",
"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/1f1783bd251d01dfbb0318b423358299/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": 1,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "hXe4X3rUT7VS",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "f764963e-9bbb-41de-aa28-d162386cf7d2"
},
"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": 2,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"1619481600.0"
]
},
"metadata": {
"tags": []
},
"execution_count": 2
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Vshl15JpUHbk",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "83bbd1c2-ade2-4ce2-86f5-0bfffbbd2218"
},
"source": [
"datetime.today().timestamp()"
],
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"1619494711.831207"
]
},
"metadata": {
"tags": []
},
"execution_count": 3
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "m2uTiOAXYok6"
},
"source": [
"# use nichelper"
]
},
{
"cell_type": "code",
"metadata": {
"id": "3Di70BlQYwdt"
},
"source": [
"!pip install -q nicHelper==0.0.76"
],
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "OEXeiZYPYp4E",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "bc483e66-e2dd-42bb-eb47-9c4cbb756d66"
},
"source": [
"from nicHelper.datetime import datestamp\n",
"datestamp()"
],
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"1619481600"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "X-NGaUeOZC8h"
},
"source": [
""
],
"execution_count": 5,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment