The strftime function of the Python time module

Source: Internet
Author: User
Tags iso 8601 month name

The Strftime () method translates to a tuple or sreuct_time representing the time specified by the format parameter returned by Gmtime () or locatime () as a string.

When T is not set, the current time is returned using the LocalTime () method. The format must be a string. The exception valueerror is suspended if T is outside the allowable range of any field.

Grammar:

The following is the syntax for the Strftime () method:

Time.strftime (Format[,t])

Parameters:

    1. T---This is the time in seconds to format.
    2. Format----This is the instruction that will be used to format the given time. The following instruction can embed a format string

Instructions:

  1. %a-Abbreviated day of the week
  2. %A-The full day of the week
  3. %b-Abbreviated month name
  4. %B-Full month name
  5. %c-Preferred date and time representation
  6. %c-century value (year divided by 100, range from 00 to 99)
  7. %d-the day ordinal of the month (01?31)
  8. %d-Similar%m/%d/%y
  9. %e-Day of the month (1?31)
  10. %g-similar to%g, but no century
  11. %G-a year that corresponds to a 4-digit number of ISO weeks (see%V)
  12. %h-Similar to%b
  13. %H-hours, using 24-hour (00?23)
  14. %I-hours, using 12-hour (01?12)
  15. %j-which day of the year (001?366)
  16. %m-month (01?12)
  17. %M-min
  18. %n-line break
  19. %p-AM or PM based on a given time value
  20. %r-time in the morning and the afternoon sign: am/pm
  21. %r-time in hour notation
  22. %s-Sec
  23. %t-Tab
  24. %T-current time, equals%h:%m:%s
  25. %u-Weekday is a number (1 to 7), Monday = 1. Warning: on Sun Solaris Sunday =1
  26. %u-the number of weeks of the year, the first Sunday as the first day of the first week
  27. %V-The week of the year ISO 8601 (01 to 53), where the 1th week is at least 4 days in the year of the first week, Monday as the first day of the week
  28. %W-the number of weeks of the year, with the first day of the first week of Monday as the first
  29. %w-week for a decimal, Sunday =0
  30. %x-date representation with no time
  31. %x-No date preferred time representation
  32. %y-One year without century (range from 00 to 99)
  33. %Y-this year, including century
  34. %Z or%Z-time zone or name or abbreviation
  35. Percent-Text% character

  

1 time.strftime (format [, t])

The strftime function of the Python time module

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.