06. Date format output parser (DatetimeOutputParser)
DatetimeOutputParser
DatetimeOutputParser can be used to parse the output of LLM into datetime format.
Copy
from dotenv import load_dotenv
load_dotenv()Copy
TrueCopy
# Set up LangSmith tracking. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging
# Enter a project name.
logging.langsmith("CH03-OutputParser")Copy
Start tracking LangSmith.
[project name]
CH03-OutputParserreference
Format codeExplainationExample
%Y
4 digit year
2024
%y
2 digit year
24
%m
2 digit month
07
%d
2 digit day
04
%H
24 hour clock
14
%I
12-hour clock
02
%p
AM or PM
PM
%M
2 digits
45
%S
2 digit seconds
08
%f
Microseconds (6 digits)
000123
%z
UTC offset
+0900
%Z
Time zone name
KST
%a
Day of the week abbreviation
Thu
%A
All days of the week
Thursday
%b
Month Abbreviation
Jul
%B
Whole month
July
%c
Full date and time
Thu Jul 4 14:45:08 2024
%x
Full date
07/04/24
%X
Total time
14:45:08
Copy
Copy
Create a chain.
Copy
Prints the results.
Copy
Copy
Last updated