barber84
Dec 10 2005, 07:15 PM
Hi,
how would I use php to check a date in the format yyyy-mm-dd to see if it has been a week since that date.
thanks,
Ben
barber84
Dec 10 2005, 08:57 PM
Problem resolved using:
echo date("Y-m-d",(time() + 60*60*24*30));
which displays today date + 30 days and I am using if else statements to see if todays date matches 30 days on from the date in the database.
Forgotten
Dec 11 2005, 02:10 AM
just to add another question to this post, how do I turn GMT into -8:00 (PST)?
barber84
Dec 11 2005, 03:03 AM
Hopefully this should help you, it just takes 8 hours away from the current time.
<?php
$time = time() - (60*60*8); //Take away 8 hours from the time the server is set to (GMT)
echo $time; // display time in PST (-8)
?>
Forgotten
Dec 11 2005, 03:34 AM
my script shows
CODE
$Time=date("g:i A T");
will echo
QUOTE
2:53 PM MST
How do I make MST say PST? Isnt there a O operator that sets timezones? I don't know how to use it.
Av-
Dec 11 2005, 07:14 AM
to set a timezone use
CODE
<?php
date_default_timezone_set('PST');
date(stuff);
?>
Forgotten
Dec 11 2005, 12:31 PM
yeah that is an undefined function... Im using php 5.1
rc69
Dec 11 2005, 04:06 PM
Just use barbers method, with a little tweaking.
CODE
echo date('g:i A', time()-(60*60)).' PST';
Forgotten
Dec 12 2005, 08:17 PM
thanks rc69!
check it out: www.adminalliance.net
phpguy
Oct 27 2009, 06:30 PM
Hi,
I'm working on a project that checks today's date against one in the mysql database. I can write a function in a php script to check. However if the php script is just sitting there; then what actually starts the process of the check function; besides an inefficient continuous loop?
Thanks
Arctic Fire
Oct 27 2009, 10:05 PM
QUOTE (phpguy @ Oct 27 2009, 07:30 PM)

Hi,
I'm working on a project that checks today's date against one in the mysql database. I can write a function in a php script to check. However if the php script is just sitting there; then what actually starts the process of the check function; besides an inefficient continuous loop?
Thanks
You would create a cron job to run the php script every day.
Demonslay
Oct 27 2009, 10:07 PM
Well, either you can have it wrapped in a function that is invoked every time a page is loaded, such as in your main configuration file or something, or you can setup a cron job. I've personally never used a cron job, but its a way of automating something for the server to execute on a set interval. You can find several tutorials on these online if not here on P2L, such as
this one if your host uses CPanel.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.