You are here: Re: i love strtotime but it is no use in New Zealand « PHP Programming Language « IT news, forums, messages
Re: i love strtotime but it is no use in New Zealand

Posted by Toby Inkster on 04/25/06 10:38

windandwaves wrote:

> HOWEVER, this obviously does not work for the day/month vs month/day
> scenario. That is, in New Zealand we use day/month/year, while the function
> assumes it to be month/day/year.

Generally what I do is something like this (pseudo-code):

<?php

function mystrtotime($date)
{
if ($date is "??/??/??" || $date is "??-??-??")
{
list($d, $m, $y) = preg_split('/\/\-/', $date);
if ($y<70)
$y += 2000;
else
$y += 1900;
}
elseif ($date is "??/??/????" || $date is "??-??-????")
list($d, $m, $y) = preg_split('/\/\-/', $date);

if (isset($d))
$date = sprintf("%04d-%02d-%02d", $y, $m, $d);

return strtotime($date);
}
?>

I'll let you work out the regular expressions for the conditionals
yourself. :-)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this 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

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