Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11352
| References | <83822ecb-3643-42c6-a2bf-0187c07d351d@a10g2000yqn.googlegroups.com> |
|---|---|
| Date | 2011-08-13 13:09 -0700 |
| Subject | Re: How do I convert String into Date object |
| From | Chris Rebert <clp2@rebertia.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2254.1313266161.1164.python-list@python.org> (permalink) |
On Sat, Aug 13, 2011 at 12:14 PM, MrPink <tdsimpson@gmail.com> wrote:
> Is this the correct way to convert a String into a Date?
> I only have dates and no time.
>
> import time, datetime
>
> oDate = time.strptime('07/27/2011', '%m/%d/%Y')
> print oDate
from datetime import datetime
the_date = datetime.strptime('07/27/2011', '%m/%d/%Y').date()
Cheers,
Chris
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 12:14 -0700
Re: How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 12:26 -0700
Re: How do I convert String into Date object Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2011-08-13 22:11 +0200
Re: How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 13:25 -0700
Re: How do I convert String into Date object Peter Otten <__peter__@web.de> - 2011-08-13 22:29 +0200
Re: How do I convert String into Date object Sibylle Koczian <nulla.epistola@web.de> - 2011-08-13 22:05 +0200
Re: How do I convert String into Date object Chris Rebert <clp2@rebertia.com> - 2011-08-13 13:09 -0700
Re: How do I convert String into Date object Roy Smith <roy@panix.com> - 2011-08-13 20:49 -0400
Re: How do I convert String into Date object MrPink <tdsimpson@gmail.com> - 2011-08-13 22:44 -0700
csiph-web