472,962 Members | 2,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,962 software developers and data experts.

Can I display a month from a number in a csv file?

Greetings from a second day newbie to php.

I think I have figured out a way to explode a field in a csv file (like
11-08-03) and implode it as 031108 and then compare it to the current
date(ymd) to display data after the current date. What I would like to now
do is use the 11 and display Nov. Can anybody help or point me in the right
direction?

Thanks.
Bill
Jul 17 '05 #1
5 2623
I noticed that Message-ID: <7eUnb.43950$9E1.180122@attbi_s52> from The
Biscuit Eater contained the following:
Greetings from a second day newbie to php.

I think I have figured out a way to explode a field in a csv file (like
11-08-03) and implode it as 031108 and then compare it to the current
date(ymd) to display data after the current date. What I would like to now
do is use the 11 and display Nov. Can anybody help or point me in the right
direction?


Any particular reason why you're not using a database for this?
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
The Biscuit Eater wrote:
Greetings from a second day newbie to php.

I think I have figured out a way to explode a field in a csv file (like
11-08-03) and implode it as 031108 and then compare it to the current
date(ymd) to display data after the current date. What I would like to now
do is use the 11 and display Nov. Can anybody help or point me in the right
direction?


My first idea (probably not the best) was:

make an array and select from that:

<?php
$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');

// do whatever you need, including
$month = 11;

// and, after being real sure 1 <= $month <= 12
echo $months[$month-1];
?>

--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #3

"Pedro" <he****@hotpop.com> wrote in message
news:bn*************@ID-203069.news.uni-berlin.de...
My first idea (probably not the best) was:

make an array and select from that:

<?php
$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');

// do whatever you need, including
$month = 11;

// and, after being real sure 1 <= $month <= 12
echo $months[$month-1];
?>


Thanks, that was where I was heading when, while driving home this evening,
I came up with something that apparently works just fine. I can now pull the
next event or all events from a csv file using the following:

<?

$readfile = file("events.txt");
for ($k=0; $k<=count($readfile)-1; $k++) {
$field = split(";",$readfile[$k]);

$date = date("Ymd");

$piece = explode("-", $field[0]);
$array = array($piece[2], $piece[0], $piece[1]);
$c = implode("", $array);
$d = date("jS",mktime(0,0,0,$piece[0],$piece[1],$piece[2]));
$m = date("M",mktime(0,0,0,$piece[0],$piece[1],$piece[2]));

if ($c >= $date) {

print ("<a class=\"noUL\" href=\"javascript:void(0);\"
onclick=\"window.open('events/$field[0].htm', 'NextEvent', 'scrollbars=yes,
resizable=yes, height=600, width=650')\">$m $d - $field[1]</A>");

exit;
}
}

?>

The csv is setup like:

11-06-2003;Beat the Pro;Individual play;tee choice;8:30 AM Shotgun
01-10-2004;Twister;(Scramble-Stableford);Four man teams (white tees)
Jul 17 '05 #4
Carved in mystic runes upon the very living rock, the last words of The
Biscuit Eater of comp.lang.php make plain:

"Pedro" <he****@hotpop.com> wrote in message
news:bn*************@ID-203069.news.uni-berlin.de...
My first idea (probably not the best) was:

make an array and select from that:

<?php
$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');

// do whatever you need, including
$month = 11;

// and, after being real sure 1 <= $month <= 12
echo $months[$month-1];
?>


Thanks, that was where I was heading when, while driving home this
evening, I came up with something that apparently works just fine. I
can now pull the next event or all events from a csv file using the
following:


Great googly-moogly! Now that's newbie code if I ever saw it! :)

$thefile = file("events.txt");
while (list(,$record) = each($thefile)) {
$fields = split(";", $record);
$stamp = strtotime("$field[0] 00:00:00");
if $stamp > time() {
[do stuff]
}
}

And you can use the date() function on $stamp to get whatever formatted
date info you want. strtotime() is your friend.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #5
I want to thank Alan and Jon for sending me in the right direction. With the
following I can pull the next golf tournament from a csv file and display a
link to a popup for more information - and in addition, display the days
until and sign up deadline. Thanks again for your help.

Seems to work nicely... http://www.mgagcai.org/

<?
$thefile = file("events.csv");
while (list(,$record) = each($thefile)) {
$field = split(";", $record);
$stamp = strtotime("$field[0]");
if (ceil(($stamp - time())/86400) >= 0) {
echo "<a href=\"javascript:void(0);\" onclick=\"window.open('/"
,date("Ymd", strtotime ($field[0])), ".html', 'NextEvent', 'scrollbars=yes,
resizable=yes, height=600, width=650')\">", date("M jS", strtotime
($field[0])), " - $field[1]</A><br />";
echo "<span class=\"sans\">";
if (ceil(($stamp - time())/86400) > 7) {
echo ceil(($stamp - time())/86400), " days away";
} else if (ceil(($stamp - time())/86400) >= 4) {
echo "Only ", ceil(($stamp - time())/86400), " days away. Sign up by
Wednesday evening.";
} else if (ceil(($stamp - time())/86400) == 3) {
echo "Only ", ceil(($stamp - time())/86400), " days away. Sign up by
this evening.";
} else if (ceil(($stamp - time())/86400) == 2) {
echo "Only ", ceil(($stamp - time())/86400), " days away. Too late to
sign up.";
} else if (ceil(($stamp - time())/86400) == 1) {
echo "Only ", ceil(($stamp - time())/86400), " day away. Too late to
sign up.";
} else {
echo "Event is today";
}
echo "</span>";
exit;
}
}
?>

---
Bill "Chessie" Hayes
http://www.billhayes.us
ICQ#: 9635690

Bakers trade bread recipes on a knead to know basis.

"Alan Little" <al**@n-o-s-p-a-m-phorm.com> wrote in message
news:Xn**************************@216.196.97.132.. .
Carved in mystic runes upon the very living rock, the last words of The
Biscuit Eater of comp.lang.php make plain:

"Pedro" <he****@hotpop.com> wrote in message
news:bn*************@ID-203069.news.uni-berlin.de...
My first idea (probably not the best) was:

make an array and select from that:

<?php
$months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');

// do whatever you need, including
$month = 11;

// and, after being real sure 1 <= $month <= 12
echo $months[$month-1];
?>


Thanks, that was where I was heading when, while driving home this
evening, I came up with something that apparently works just fine. I
can now pull the next event or all events from a csv file using the
following:


Great googly-moogly! Now that's newbie code if I ever saw it! :)

$thefile = file("events.txt");
while (list(,$record) = each($thefile)) {
$fields = split(";", $record);
$stamp = strtotime("$field[0] 00:00:00");
if $stamp > time() {
[do stuff]
}
}

And you can use the date() function on $stamp to get whatever formatted
date info you want. strtotime() is your friend.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: JP SIngh | last post by:
Hi All I have a tricky question wonder if anyone can help. I store dates in my table as FDate TDate NoDays Where Fdate is From Date
11
by: Jim | last post by:
I have been using the javascript below on a web page since last August to show the "Site updated" month only minus a month, which has been very successful, but January is showing a "undefined 2004"...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
1
by: Need Helps | last post by:
Hello. I'm writing an application that writes to a file a month, day, year, number of comments, then some strings for the comments. So the format for each record would look like:...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
6
by: Mark | last post by:
Hello all, I have the following file.txt storing these kind of values: Name: John Doe E-mail: john@doe.com Phone: 555 865 8901 Address: 71 Huntington Ln. (33444) FL - Delray Beach US Member...
5
by: peck2000 | last post by:
This has been driving me up the wall for a couple of weeks. I set out to convert my comic collection check list (geek that I am!) from a static HTML table to a dynamic ASP generated one. The...
1
by: Mr. Ed | last post by:
I have a table that tracks client contact. I want to create a report that checks to see if contact has been made in a specific month (passed parameter). If no contact has been made for that...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I donít have any data for that month. I have an Access database where I want...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.