Parsing a PHP String without Delimiters

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-01-2003
AttilaTheChris
 
Posts: n/a
Default Parsing a PHP String without Delimiters

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
Reply With Quote
  #2 (permalink)  
Old 10-02-2003
BKDotCom
 
Posts: n/a
Default Re: Parsing a PHP String without Delimiters

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.

Reply With Quote
  #3 (permalink)  
Old 10-02-2003
Tom Thackrey
 
Posts: n/a
Default Re: Parsing a PHP String without Delimiters


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
Reply With Quote
  #4 (permalink)  
Old 10-02-2003
BKDotCom
 
Posts: n/a
Default Re: Parsing a PHP String without Delimiters

"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;
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0