<jupyter_start><jupyter_text>The  **datetime** module is part of the Python standard library* From string to datetime `.strptime()`* Datetime to String `.strftime()` , `isoformat()`<jupyter_code>from datetime import datetime

d = datetime.strptime('30/03/2021','%d/%m/%Y')
display(d)
print(d)

s = d.strftime('%d/%m/%Y')
display(s)

i= d.isoformat()
display(i)
display(d.day)
display(d.month)
display(d.year)
display(datetime.now())
display(datetime.utcnow())<jupyter_output><empty_output><jupyter_text>timezones* Naive datetime objects have no timezone data* Aware datetime objects have a timezone* Timezone data is available via the  `pytz` module via the timezone object* Aware objects have  `.astimezone()` so you can get the time in another timezone<jupyter_code>from pytz import timezone

dt = datetime.strptime('21/12/2020 02:39PM', '%d/%m/%Y %H:%M%p')
eu_tz = timezone('Europe/Dublin')
a_tz = timezone('America/Recife')
eu_dt = dt.replace(tzinfo=eu_tz)
a_dt = eu_dt.astimezone(a_tz)
display(eu_dt, a_dt)<jupyter_output><empty_output><jupyter_text>timedeltais used to represent an amount of change in timeUsed to add or subtract a set amount of time from a datetime object<jupyter_code>from datetime import timedelta
flashback = timedelta(days=90)
print(eu_dt - flashback)
print(eu_dt + flashback)<jupyter_output>2020-09-22 02:39:00-00:25
2021-03-21 02:39:00-00:25
{'fraction_non_alphanumeric': 0.13202042304886943, 'fraction_numerical': 0.04230488694383661, 'mean_word_length': 6.664804469273743, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '528792', 'license': 'CC0-1.0', 'n_tokens_mistral': 545, 'n_tokens_neox': 498, 'n_words': 128, 'path': 'notes_on_data_manipulation/notes_on_datetime_module.ipynb', 'repo_name': 'blazaropinto/my_notes_learning_DS', 'size': '1371'}