This is a discussion on Parsing a PHP String without Delimiters within the PHP Language forums, part of the PHP Programming Forums category; I'm not sure if my last post went through (so my apologies if this is a repeat). I need ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm not sure if my last post went through (so my apologies if this is a repeat).
I need to figure out how to separate a string that contains no delimters. In this case, a MySQL timestamp ('20031001155704 ') into date and time units. Is there a date function for this? If not, I would be just as happy with a string function. Thanks, Chris |
|
|||
|
cmh_jobs@yahoo.com (AttilaTheChris) wrote in message > I need to figure out how to separate a string that contains no delimters.
> In this case, a MySQL timestamp ('20031001155704 ') into date and time units. > > Is there a date function for this? A question that can be answered easily on your own.. http://www.php.net/ why wait hours when you can have immediate answers. http://us3.php.net/manual/en/function.strtotime.php and look at all those other handy date functions on the left. $epoch_timestamp = strtotime('20031001155704'); or perhaps you should be using a mysql date function (see http://www.mysql.com)? > If not, I would be just as happy with a string function. |
|
|||
|
On 1-Oct-2003, BradKent@swbell.net (BKDotCom) wrote: > cmh_jobs@yahoo.com (AttilaTheChris) wrote in message > I need to figure > out how to separate a string that contains no delimters. > > In this case, a MySQL timestamp ('20031001155704 ') into date and time > > units. > > > > Is there a date function for this? > A question that can be answered easily on your own.. > http://www.php.net/ > why wait hours when you can have immediate answers. > > http://us3.php.net/manual/en/function.strtotime.php > and look at all those other handy date functions on the left. > > $epoch_timestamp = strtotime('20031001155704'); Before you cast the RTFM stone you might want to RTFM yourself. strtotime does not parse '20031001155704' you have to remove the seconds and add a space between the date and time to make it work i.e. $epoch_timestamp = strtotime('20031001 1557'); -- Tom Thackrey www.creative-light.com |
|
|||
|
"Tom Thackrey" <tomnr@creative-light.com> wrote in message news:<bsNeb.10944$D82.283@newssvr25.news.prodigy.c om>...
> Before you cast the RTFM stone you might want to RTFM yourself. > I guess bum-info is one of the hazzards of usenet? How about this? $array = sscanf('20031001155704','%4d%2d%2d%2d%2d%2d'); list($year,$month,$day,$hour,$min,$sec) = $array; |