xfx_fusion xfx_idrive2 xfx_usbloadpro_fusion xfx_bluetooth xfx_ipc xfx_printers xfx_usbloadpro xfx_printerxd.
Development. KANSAI ELECTRONICS CO., LTD.. LSI ILO RAID Controllers. KANSAI ELECTRONICS CO., LTD.. KANSAI ELECTRONICS CO., LTD..
Official Site. This site is not affiliated with OCZ Technology Corporation. Flash Memory Toolkit 2.01 Full Version Serial Number Rar 18.Q:
How to print a date in a given month and year with the first day of the month
I'm working on a school project, and I'm having issues formatting the date in python.
I want to format the date to be the first day of the month, however I also want to be able to print that out in just a month, year format.
Example: I want to print "April 2, 2014" but when I try to do that the date is "01-04-2014".
In C# it's simple:
DateTime.Now.ToString("MMMM dd, yyyy");
But I have no idea how to do this in Python
A:
Note: Month abbreviations are inconsistent between python's date/time objects and a calendrical format. For this reason, I've written the code below as explicitly as possible.
First, to the pythonic way:
# Day is the first day of the month. Note month_abbrev as the
# argument is the 'MMMM' style, not the 'M' as it is in C#.
from datetime import datetime, date
def first_of_month(month_abbrev, day):
d = datetime.strptime(month_abbrev +'' + day, '%B'+ day)
return d.date()
# Example usage:
print(first_of_month('April', 1))
# 2014-04-01
The direct calendrical way is to use the strftime() function, using the '%m' %y syntax (as used by strftime for months):
import datetime
def first_of_month(month_abbrev, be359ba680
Related links:
Comments