Ask a Question related to PHP Development, Design and Development.
-
The Biscuit Eater #1
if a number is say xx how to make it 20xx, but ignore if it is xxxx?
Ok, I am almost finished with what I was trying to accomplish (pulling
future events from a csv file where the first field is the date). I was
concerned that though I wanted dates entered as mm-dd-yyyy, people often
drop the leading zeros and enter yy. I think I have figured out a way to
cover the leading zeros using sprintf. The problem is now converting
something like 04 to 2004.
This is what I have so far:
<?
$readfile = file("events.txt");
for ($k=0; $k<=count($readfile)-1; $k++) {
$field = split(";",$readfile[$k]);
$date = date("Ymd");
$piece = explode("-", $field[0]);
$day = sprintf("%02d", $piece[1]);
$month = sprintf("%02d", $piece[0]);
$array = array($piece[2], $month, $day);
$c = implode("", $array);
if ($c >= $date) {
print ("$month/$day/$piece[2] $field[1] $field[2], etc.<br>");
}
}
?>
Any thoughts would be appreciated.
Bill
The Biscuit Eater Guest
-
Web.config: <allow users="xxxx" /> Where does xxxx come from?
I'm using Forms Authentication. When I authenticate a user from a database, I use the following line:... -
Need to Format a zipcode into xxxxx-xxxx.
I guess that you can't do this with the property window of datagrid control. Probably need an itemdatabound event. How can I program an... -
make model ignore collision from modelsUnderRay
Is there a quick and easy way to stop a camera which has a bounding sphere from models under ray from colliding with one or two models while... -
No PDF file was created because xxxx.doc does not exist
Adobe Professional 6.01 Windows XP Novell/Windows Network Compaq 2 Ghz, 2GB RAM I am: Help Desk Tech User can't create PDF documents. She does... -
aspnet_wp.exe (PID: xxxx) stopped unexpectedly.
Hi all. I'm having a nasty problem. A client's website was originally written with classic ASP. They requested a new portion of the site that was... -
Jon Kraft #2
Re: if a number is say xx how to make it 20xx, but ignore if it is xxxx?
The Biscuit Eater <BoulderBill*NOSPAM*@comcast.net> wrote:
$c = date("Ymd", strtotime($field[0]));> Ok, I am almost finished with what I was trying to accomplish (pulling
> future events from a csv file where the first field is the date). I was
> concerned that though I wanted dates entered as mm-dd-yyyy, people often
> drop the leading zeros and enter yy. I think I have figured out a way to
> cover the leading zeros using sprintf. The problem is now converting
> something like 04 to 2004.
>
> This is what I have so far:
>
> <?
>
> $readfile = file("events.txt");
>
> for ($k=0; $k<=count($readfile)-1; $k++) {
> $field = split(";",$readfile[$k]);
>
> $date = date("Ymd");
>
Hi Bill,> if ($c >= $date) {
Much easier - use strtotime(). See above.
HTH;
JOn
Jon Kraft Guest



Reply With Quote

