Jeff Pang wrote:
Hello,list,

Maybe it's a simple problem,but I don't know how to do it.

I have a time string,for example:
Thu Mar  9 23:04:03 2006

How can  I get it translated to unix timestamp,for example:
1141916656

Thanks.

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com


POSIX has a function mktime that converts arrays returned by localtime back in seconds from the epoch. You would have to parse the date string into the appropriate array.

See `perldoc POSIX` and search for "mktime"
See `man mktime` and search for "mktime"

I have never used the function myself so its implementation is left as an exercise for the reader.


--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
  SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

"This statement is true but unprovable."
  Kurt Godel

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to