How to format datetime values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • A.M

    #1

    How to format datetime values

    Hi,



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



    Thank you,

    Alan




  • BartlebyScrivener

    #2
    Re: How to format datetime values

    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

    Comment

    • skip@pobox.com

      #3
      Re: How to format datetime values


      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

      Comment

      • Paul Osman

        #4
        Re: How to format datetime values

        On 1-Jun-06, at 2:55 PM, A.M wrote:
        [color=blue]
        > Hi,
        >
        >
        >
        > I have a datetime value and want to format it to "June 1, 2006"
        > shape. How
        > can I do that?
        >
        >
        >
        > Thank you,
        >
        > Alan[/color]

        Why don't you just post the specs to your program and maybe someone
        will write it *FOR* you in less than a day?

        This is quicker than waiting for replies:

        Python Tutorial
        Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax an...


        Module Index


        Cheers,

        --
        Paul Osman

        Comment

        • A.M

          #5
          Re: How to format datetime values


          "BartlebyScrive ner" <rpdooling@gmai l.com> wrote in message
          news:1149190242 .446952.52180@j 55g2000cwa.goog legroups.com...[color=blue]
          > 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
          >[/color]

          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.


          [color=blue][color=green]
          >> It's the equivalent of me asking you:
          >> and will you teach me about strings? Oh, and what's an object?[/color][/color]



          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.


          Comment

          • Laurent Pointal

            #6
            Re: How to format datetime values

            A.M a écrit :[color=blue]
            > "BartlebyScrive ner" <rpdooling@gmai l.com> wrote in message
            > news:1149190242 .446952.52180@j 55g2000cwa.goog legroups.com...[color=green]
            >> 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
            >>[/color]
            >
            > Well, I did investigate all tutorial and google and I wasn't able to find
            > any built-in way for datetime formatting in Python.[/color]

            Really ?

            For time formating... have you really really looked at module... 'time'?
            [color=blue]
            > 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.[/color]

            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:



            A+

            Laurent.

            Comment

            Working...