![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 27104 Articles for Server Side Programming
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
1K+ Views
You can very easily store and retrieve date into Sqlite3 database using the sqlite3 module. When inserting the date in the database, pass the date directly and Python handles it automatically.Exampleimport sqlite3 import datetime conn = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) conn.execute('''CREATE TABLE TEST (ID TEXT PRIMARY KEY NOT NULL, DATE DATE)''') # Save changes conn.commit() # Insert the object directly conn.execute("INSERT INTO TEST (ID, DATE) VALUES (?, ?)", ('My date', datetime.date(2018, 1, 4))) conn.commit() print("Record inserted")OutputThis will give the output −Record insertedNow when you will fetch the values from the database, you will get the date already parsed to the datetime object.Exampleimport ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
217 Views
There are many modules available in both the standard library and the PiPy repository for date manipulation. The most popular among these libraries are the following(in no particular order) −datetime (Standard library) − The datetime module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic is supported, the focus of the implementation is on efficient attribute extraction for output formatting and manipulation.time(Standard library) − This module provides various time-related functions. Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
1K+ Views
It is not possible to get a suffix like st, nd, rd and th using the strftime function. The strftime function doesn't have a directive that supports this formatting. You can create your own function to figure out the suffix and add it to the formatting string you provide.Examplefrom datetime import datetime now = datetime.now() def suffix(day): suffix = "" if 4
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
8K+ Views
In this article, we will show you how to find only Monday's date using Python. We find the last Monday, next Monday, nth Monday's dates using different methods− Using timedelta() function Using relativedelta() function to get Last Monday Using relativedelta() function to get next Monday Using relativedelta() function to get next nth Monday Using timedelta() function to get previous nth Monday Method 1: Using timedelta Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Use the import keyword, to import the, datetime (To work with Python dates and times) module. Use ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
12K+ Views
You can use the fromtimestamp function from the datetime module to get a date from a UNIX timestamp. This function takes the timestamp as input and returns the datetime object corresponding to the timestamp.Exampleimport datetime timestamp = datetime.datetime.fromtimestamp(1500000000) print(timestamp.strftime('%Y-%m-%d %H:%M:%S'))OutputThis will give the output −2017-07-14 08:10:00
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
11K+ Views
In Python, you can convert a string to date object using the strptime() function. Provide the date string and the format in which the date is specified. Example import datetime date_str = '29/12/2017' # The date - 29 Dec 2017 format_str = '%d/%m/%Y' # The format datetime_obj = datetime.datetime.strptime(date_str, format_str) print(datetime_obj.date())OutputThis will give the output −2017-12-29
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
674 Views
You can get the Python date object for last wednesday using some Python date math. Whatever the day of the week it is today, subtracting 2 from it and taking the modulus of the result by 7 will give us how back was wedenesday. examplefrom datetime import date from datetime import timedelta today = date.today() offset = (today.weekday() - 2) % 7 last_wednesday = today - timedelta(days=offset)OutputThis will give you the output −2017-12-27
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
2K+ Views
There is no standard JSON format for dates. Although JavaScript does have a standard date format that is human readable, sorts correctly, includes fractional seconds(which can help re-establish chronology) and conforms to ISO 8601. You can convert a Python date to the JS date format using the strftime function and deserialize it using the client that needs this date. To get an ISO 8601 date in string format in Python 3, you can simply use the isoformat function. It returns the date in the ISO 8601 format. For example, if you give it the date 31/12/2017, it'll give you the ... Read More
![Vikram Chiluka](https://www.tutorialspoint.com/assets/profiles/495654/profile/60_4081994-1659334126.jpg)
33K+ Views
In this article, we will show you how to sort a Python date string list. Now we see 3 methods to accomplish this task− Now we see 2 methods to accomplish this task− Using sort() and lambda functions Using sort() function Using sorted function Method 1: Using sort() and lambda functions Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Use the import keyword, to import the datetime from datetime module (To work with dates and times, Python has a module called datetime). Create a variable to store the input list ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
28K+ Views
A UNIX timestamp is the total number of seconds that have been counted since the epoch. An epoch is the starting point of time and is platform-dependent. The epoch is January 1, 1970, 00:00:00 (UTC) on Windows and most Unix systems, and leap seconds are not included in the time in seconds since the epoch. In this article, we going to see how to convert a python date to a UNIX timestamp. Datetime to UNIX timestamp Here we convert a python date to a UNIX timestamp by using the time.mktime() method. In this example, we initially imported the datetime module. ... Read More