Computing.Net > Forums > Web Development > Date in php

Date in php

Reply to Message Icon

Original Message
Name: DJ-BROWNTHUG
Date: June 2, 2004 at 17:54:24 Pacific
Subject: Date in php
OS: XP
CPU/Ram: 192mb ( Intel celeron pro
Comment:

Hi can some one give me the code of the day like ( Thursday 3rd June ) it changes evry day


Report Offensive Message For Removal


Response Number 1
Name: DJ-BROWNTHUG
Date: June 2, 2004 at 17:55:21 Pacific
Subject: Date in php
Reply: (edit)

and can some one gimme the Text counter code 2 plz


Report Offensive Follow Up For Removal

Response Number 2
Name: Jamie_McCoy
Date: June 3, 2004 at 01:17:13 Pacific
Subject: Date in php
Reply: (edit)

$date = date("d M Y");


search on planetsourcecode for a counter, theirs loads of them


Sign Me Guestbook!

jaymc.co.nr


Report Offensive Follow Up For Removal

Response Number 3
Name: jam14online
Date: June 3, 2004 at 02:09:00 Pacific
Subject: Date in php
Reply: (edit)

Here's a simple hit counter in PHP:

<?php

//Path to counter file
$file = "count.dat";

//Get number of hits at the moment
$counter = file_get_contents($file);

//Add one to this number
$counter++;

//Open data file for writing
$handle = fopen($file, "w");

//Write new number
fwrite($counter);

//Close file
fclose($handle);

//Give number to browser
echo $counter;

?>

Copy and paste that code and save it as counter.php. Then, all you have to do is make a file called count.dat (or whatever you name it) and then change the permissions in CPanel or an FTP program so that it is writeable by all.

Then, just put <?php require_once("counter.php"); ?> in whichever page you want to have the hit counter count hits for. By the way, this is one of the simplest counters around. It doesn't count individual hits (it counts every time the page is accessed) and it can only work for one page at a time. You would have to make a counter.php and count.dat file for every page (but change the names slightly, e.g. counter_links.php and counter_links.dat).

Otherwise, I recommend you follow what Jamie said and find someone else's free source code from another website.

I hope this helps,


James



Report Offensive Follow Up For Removal

Response Number 4
Name: FBI Agent
Date: June 3, 2004 at 20:32:34 Pacific
Subject: Date in php
Reply: (edit)

or you could just not use the counter.php and just add the


<?php

//Path to counter file
$file = "count.dat";

//Get number of hits at the moment
$counter = file_get_contents($file);

//Add one to this number
$counter++;

//Open data file for writing
$handle = fopen($file, "w");

//Write new number
fwrite($counter);

//Close file
fclose($handle);

//Give number to browser
echo $counter;

?>


in your index.html (or whatever). that'd be a lot simpler and easier

FBI_Agent


Report Offensive Follow Up For Removal

Response Number 5
Name: FBI Agent
Date: June 3, 2004 at 21:16:12 Pacific
Subject: Date in php
Reply: (edit)

also, if you wanted to make the "hit number" look cool, you could just add that in the script too. like

//Give number to browser
echo "[b][font face='Eurostile' color='#123456']$counter[/font][/b]";


then i'd look cool. i dont have my webserver open right now to test it, but it should work.

... actually, im gonna test it to see how it looks ;-)


yeah, kinda like this.

<?php

//Path to counter file
$file = "count.html";

//Get number of hits at the moment
$counter = file_get_contents($file);

//Add one to this number
$counter++;

//Open data file for writing
$handle = fopen($file, "w");

//Write new number
fwrite($handle, $counter);

//Close file
fclose($handle);

//Give number to browser
echo "[b][font face='Eurostile' color='#123456']$counter[/font][/b]";

?>


looks awesome ;) then if ytou have a css file, you could make a class that makes a background color and put that in the font, i'd be even better ][font face='Eurostile' color='#123456']

FBI_Agent



Report Offensive Follow Up For Removal


Response Number 6
Name: DJ-BROWNTHUG
Date: June 5, 2004 at 06:50:11 Pacific
Subject: Date in php
Reply: (edit)

its not working

http://www.brownthug.ibfreeuk.com/test/103.php


Report Offensive Follow Up For Removal

Response Number 7
Name: FBI Agent
Date: June 5, 2004 at 14:02:45 Pacific
Subject: Date in php
Reply: (edit)

lol, you dont use the [ ]'s, you cant post a lot of the basic html in these forums, so i cant say the actual stuff...


replace [ with <

and ] with >

FBI_Agent



Report Offensive Follow Up For Removal

Response Number 8
Name: FBI Agent
Date: June 5, 2004 at 14:05:55 Pacific
Subject: Date in php
Reply: (edit)

fyi, fix your "enter" button on your flash intro. the cursor has to be on the letter for it to work, make it so when it goes inbetween the letters that it wors too.

kinda hard to udnerstand, but i cant get it any simpler right now

FBI_Agent


Report Offensive Follow Up For Removal

Response Number 9
Name: DJ-BROWNTHUG
Date: June 5, 2004 at 15:30:00 Pacific
Subject: Date in php
Reply: (edit)

Well i'm not really good in flash i try to fix that 2 but i can u hav any idea how can i fix that


Report Offensive Follow Up For Removal

Response Number 10
Name: FBI Agent
Date: June 6, 2004 at 13:20:02 Pacific
Subject: Date in php
Reply: (edit)

no, i dont know crap about flash. good luck with that though

FBI_Agent


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Date in php 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge