|
1 | | -# DateTime |
2 | | - |
3 | | -The datetime module supplies classes for manipulating dates and times. |
4 | | -for ex: to Import the datetime module and display the current date: |
5 | | - |
6 | | -import datetime |
7 | | -x = datetime.datetime.now() |
8 | | -print(x) |
9 | | -When we execute the code from the example above the result will be: |
10 | | - |
11 | | -2021年01月14日 23:14:32.037299 |
12 | | -The date contains year, month, day, hour, minute, second, and microsecond. |
13 | | - |
14 | | -method for saving it as a different file once code is executed: |
15 | | -The datetime object has a method for formatting date objects into readable strings. |
16 | | -The method is called strftime(), and takes one parameter, format, to specify the format of the returned string: |
17 | | - |
18 | | -## Setup instructions |
19 | | - |
20 | | -actually we have used datetime library of python so if its not installed previously please run command pip install DateTime in terminal |
21 | | -Now simply run the code and set the output in the newly formed file with the name as current date . |
22 | | - |
23 | | -## Output |
24 | | - |
25 | | -the output file is formed with the name of current date and time and the content of file as per script of code. |
26 | | - |
27 | | -## Author(s) |
28 | | - |
29 | | -vaishnavi jha |
| 1 | +# DateTime |
| 2 | + |
| 3 | +The datetime module supplies classes for manipulating dates and times. |
| 4 | +for ex: to Import the datetime module and display the current date: |
| 5 | + |
| 6 | +import datetime |
| 7 | +x = datetime.datetime.now() |
| 8 | +print(x) |
| 9 | +When we execute the code from the example above the result will be: |
| 10 | + |
| 11 | +2021年01月14日 23:14:32.037299 |
| 12 | +The date contains year, month, day, hour, minute, second, and microsecond. |
| 13 | + |
| 14 | +method for saving it as a different file once code is executed: |
| 15 | +The datetime object has a method for formatting date objects into readable strings. |
| 16 | +The method is called strftime(), and takes one parameter, format, to specify the format of the returned string: |
| 17 | + |
| 18 | +## Setup instructions |
| 19 | + |
| 20 | +actually we have used datetime library of python so if its not installed previously please run command pip install DateTime in terminal |
| 21 | +Now simply run the code and set the output in the newly formed file with the name as current date . |
| 22 | + |
| 23 | +## Output |
| 24 | + |
| 25 | +the output file is formed with the name of current date and time and the content of file as per script of code. |
| 26 | + |
| 27 | +## Author(s) |
| 28 | + |
| 29 | +vaishnavi jha |
0 commit comments