I've searched CPAN, but everything I can find (e.g., DateTime::Format::DBI) goes the other way, creating a datetime string from a DateTime object. I need to do the reverse, creating a DateTime object from a datetime string that comes from a MySQL database.

Of course, I could parse the datetime string and feed the individual bits to DateTime::new(), but shouldn't the various DateTime modules on CPAN provide a function to do this? I mean, I could write this easily enough, but it just astounds me that it isn't already there. Where did I miss it?

Alternately, if it's not there, how do I go about writing one and submitting it? I've not written a module as yet, much less anything worthy of CPAN... I'm willing to learn, and I have read the chapter in on h2xs in Effective Perl Programming, but I don't have that book here, and... my memory is imperfect, and... this seems like something useful enough to include in the existing DateTime::Format::DBI modules, and in short I don't really know where to begin. I can put together the function itself easily enough, but the rest of the details are daunting me.


Quidquid latine dictum sit altum viditur.

In reply to Converting MySQL datetime values to DateTime objects by jonadab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.