Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Date processor

by mr.nick (Chaplain)
on Feb 23, 2001 at 22:41 UTC ( [id://60521]=note: print w/replies, xml ) Need Help??


in reply to Date processor

I'm not sure what format MySQL's date field is, but Time::ParseDate will parse your example string into a Unix format (# seconds since the epoch).
use Time::ParseDate; my $time=parsedate("2-19-01 3:22 PM"); print scalar localtime($time),"\n";

Replies are listed 'Best First'.
Re: Re: Date processor
by tadman (Prior) on Feb 23, 2001 at 22:48 UTC
    The easy way to use this more elegant approach of mr.nick would be to INSERT using the MySQL helper function:     INSERT INTO x (y) VALUES (FROM_UNIXTIME(?)); You might want to check out 7.4.11 of the MySQL docs for more detailed information.
Re: Re: Date processor
by sierrathedog04 (Hermit) on Feb 24, 2001 at 00:17 UTC
    I'm with you. I think that using CPAN modules for converting dates, XML etc. is preferable to rolling one's own regexes. There is just too much opportunity for mischief with malformed dates, leap years, invalid input, etc.

    Personally I prefer Date::Manip for these sorts of tasks, but to each his own. Or a Serge Gainsbourg said, "A son gout est l'appetit, l'appetit est a son gout." (One's taste is according to one's appetite, one's appetite is according to one's taste.")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://60521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-29 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found