How to format datetime values

A

A.M

Hi,



I have a datetime value and want to format it to "June 1, 2006" shape. How
can I do that?



Thank you,

Alan
 
B

BartlebyScrivener

Are you trying to get banned, or what?

It's the equivalent of me asking you:

Hey, does Ruby have anything like dictionaries and will you teach me
about strings? Oh, and what's an object?

Go read the bleeping tutorial.

rd
 
S

skip

Alan> I have a datetime value and want to format it to "June 1, 2006"
Alan> shape. How can I do that?

Again, Python's introspection capabilities to the rescue:

% pydoct datetime
Help on module datetime:

NAME
datetime - Fast implementation of the datetime type.
...
class datetime(date)
| datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
...
| strftime(...)
| format -> strftime() style string.

Skip
 
A

A.M

BartlebyScrivener said:
Are you trying to get banned, or what?

It's the equivalent of me asking you:

Hey, does Ruby have anything like dictionaries and will you teach me
about strings? Oh, and what's an object?

Go read the bleeping tutorial.

rd

Well, I did investigate all tutorial and google and I wasn't able to find
any built-in way for datetime formatting in Python. In fact I cannot find
any way to format a long integer into 99,999,9999 format. I know how to
format strings with C printf like formatter, but I am sure what I am trying
to do can't be done with C printf formatting.



I also found that mx.DateTime perfectly does date formatting and much more,
but I don't want to add another step to the deployment process.





The answer to this post could be just a function name. I don't think I asked
about broad concepts such as the object or strings. What I am asking here is
just a clue.
 
L

Laurent Pointal

A.M a écrit :
Well, I did investigate all tutorial and google and I wasn't able to find
any built-in way for datetime formatting in Python.

Really ?

For time formating... have you really really looked at module... 'time'?
In fact I cannot find
any way to format a long integer into 99,999,9999 format. I know how
to format strings with C printf like formatter, but I am sure what I
am trying to do can't be done with C printf formatting.

For long integer formating like your example, its not direct - maybe
look at locale formating of numbers (module... 'locale').


And I recently annouce the PQRC (on clp.announce), which can gives you
some directions:
http://www.limsi.fr/Individu/pointal/python/pqrc/


A+

Laurent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top