MindPalette Discussion Forum

PHP Time Problem

MindPalette tutorials and scripts

PHP Time Problem

Postby street253 on 02/21/2008 @ 13:33

Hi am a new member here and i really dont know where to post help for php and stuff so if i am posting in the wrong section feel free to move my topic to the right section.

Now i have a php time script that shows specific messages at a certain time but seeing that am a noob in php i really dont know how to set the time for am and pm.

Code
Code: Select all
<?php

$timeOffset = 0; // in hours, positive or negative
$nowHour = date("H", time() + (3600 * $timeOffset)) + 0;

if ($nowHour >= 2 && $nowHour < 3)
   $message = 'The Snowager is asleep take a <a href="http://www.neopets.com/winter/snowager.phtml">visit</a> to see what happens.';
else if ($nowHour = 10 && $nowHour < 11)
   $message = 'The Snowager is asleep take a <a href="http://www.neopets.com/winter/snowager.phtml">visit</a> to see what happens 2 check.';
else if ($nowHour >= 1 && $nowHour < 12)
   $message = 'Snowager is asleep 25';
   
else if ($nowHour >= 3 && $nowHour < 4)
   $message = 'Snowager is asleep 266';
   
else if ($nowHour >= 1 && $nowHour < 10)
   $message = 'Snowager is asleep 258';


print($message);

?>


Thanks in advance.
street253
 
Posts: 2
Joined: 02/21/2008 @ 13:25

Re: PHP Time Problem

Postby Nate Baldwin on 02/22/2008 @ 10:11

the script you pasted is using 24 hour time, so if you wanted 3pm, you'd just enter it as 15.
Nate Baldwin
Site Admin
 
Posts: 3724
Joined: 04/25/2003 @ 19:05

Re: PHP Time Problem

Postby street253 on 02/23/2008 @ 06:34

wow thanks for the help.
street253
 
Posts: 2
Joined: 02/21/2008 @ 13:25

Good post

Postby Gossioii9 on 04/18/2009 @ 08:19

Good post! I plan to move into this stuff after I’m done with school, as most of it is time consuming. It’s a great post to reference back to. My blog needs more time to gain in popularity anyway.
Gossioii9
 
Posts: 3
Joined: 03/23/2009 @ 01:14


Return to Tutorials and Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron