Parsing a PHP String without Delimiters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AttilaTheChris

    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 ('2003100115570 4 ') 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
  • BKDotCom

    #2
    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.[color=blue]
    > In this case, a MySQL timestamp ('2003100115570 4 ') into date and time units.
    >
    > Is there a date function for this?[/color]
    A question that can be answered easily on your own..
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.

    why wait hours when you can have immediate answers.

    Parse about any English textual datetime description into a Unix timestamp

    and look at all those other handy date functions on the left.

    $epoch_timestam p = strtotime('2003 1001155704');

    or perhaps you should be using a mysql date function (see http://www.mysql.com)?
    [color=blue]
    > If not, I would be just as happy with a string function.[/color]

    Comment

    • Tom Thackrey

      #3
      Re: Parsing a PHP String without Delimiters


      On 1-Oct-2003, BradKent@swbell .net (BKDotCom) wrote:
      [color=blue]
      > cmh_jobs@yahoo. com (AttilaTheChris ) wrote in message > I need to figure
      > out how to separate a string that contains no delimters.[color=green]
      > > In this case, a MySQL timestamp ('2003100115570 4 ') into date and time
      > > units.
      > >
      > > Is there a date function for this?[/color]
      > 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_timestam p = strtotime('2003 1001155704');[/color]

      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_timestam p = strtotime('2003 1001 1557');

      --
      Tom Thackrey

      Comment

      • BKDotCom

        #4
        Re: Parsing a PHP String without Delimiters

        "Tom Thackrey" <tomnr@creati ve-light.com> wrote in message news:<bsNeb.109 44$D82.283@news svr25.news.prod igy.com>...
        [color=blue]
        > Before you cast the RTFM stone you might want to RTFM yourself.
        >[/color]

        I guess bum-info is one of the hazzards of usenet?

        How about this?
        $array = sscanf('2003100 1155704','%4d%2 d%2d%2d%2d%2d') ;
        list($year,$mon th,$day,$hour,$ min,$sec) = $array;

        Comment

        Working...