Reply to Re: Splitting date into chunks

Your name:

Reply:


Posted by BKDotCom on 11/29/07 18:29

On Nov 28, 10:13 pm, Jason Carlton <jwcarl...@gmail.com> wrote:
> I'm sure this is an easy one, but I can't seem to find it! I have the
> date and time as:
>
> # Nov 28, 2007, 11:11:14pm
> $timestamp = 20071128231114;
>
> In Perl, I would split this up as:
>
> my ($year, $month, $day, $hr, $min, $sec) = $timestamp =~ /(\d{4})(\d
> \d)(\d\d)(\d\d)(\d\d)(\d\d)/;
>
> How do I do the same thing in PHP? I know that I can use substr, of
> course, but there has to be a better way that I'm overlooking.
>
> TIA,
>
> Jason

I'm a bit slow, but I'd accomplish it thusly:

$datetime = 20071128231114;
list($year, $month, $date, $hour, $minute, $second) =
sscanf($datetime,'%4s%2s%2s%2s%2s%2s');

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация