Open In App

ctime() Function Of Datetime.date Class In Python

Last Updated : 28 Jul, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

The ctime() function is used to return a string containing the date and time.

Syntax: ctime()

Parameters: This function does not accept any parameter.

Return values: This function returns a string containing the date and time.

The format of the string representation:

  • The string is of 24-character length.
  • Week is printed as a three-letter word.
Sun, Mo, Tue, Wed, Thu, Fri, Sat
  • Months are represented as three-digit letters
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
  • The day of the month is represented as a two-digit number
  • Time is represented in HH:MM:SS format
  • The year is a 4 digit number

Example 1: Getting a string containing the date and time

Output:

1627282355.0111642
Date for Timestamp used is: 2021-07-26
Today's date: Mon Jul 26 00:00:00 2021

Example 2: Getting a string containing the date and time

Output:

The date: Sun Feb 10 00:00:00 2013

Next Article
Article Tags :
Practice Tags :

Similar Reads