#1 (permalink)  
Old 08-30-04, 03:22 AM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Dates

Hi,
If i have

PHP Code:

$date date('Y-M-'); 

which would read, 2004-09-

How do I make it, 2004-08- , which is basically going down 1 month and how do I make it go down 2 months ?

Cheers
Reply With Quote
  #2 (permalink)  
Old 08-30-04, 04:04 AM
eq1987 eq1987 is offline
Wannabe Coder
 
Join Date: Dec 2003
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Here's a few ways:

PHP Code:

<?php

$year 
date('Y');
$month date('m');
echo 
$year " - " $month 1;
// or
$another_month $month 1;
echo 
$new_month;
// or
$yet_another_month date('m') - 1;
echo 
$newest_month;
?>
Reply With Quote
  #3 (permalink)  
Old 08-30-04, 04:31 AM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
cheers, there perfect, ive another problem maby you can help,

iam trying to use if statements to change between querys

how do I check if a variable with

2004-07-01 is like 2004-07-

The second date is missing the day numbers. how can that be down in a if statement like..

PHP Code:

if($date_a == '2004-07-')

 {
     .......... 
Reply With Quote
  #4 (permalink)  
Old 08-30-04, 01:49 PM
eq1987 eq1987 is offline
Wannabe Coder
 
Join Date: Dec 2003
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
It's possible, but I unfortuneately can't remember the command. Ill look on php.net, but hopefully someone else can help.

There may be an easier way, depending on how you get the 2 dates. Is one input by a user?
Reply With Quote
  #5 (permalink)  
Old 09-01-04, 04:55 PM
Eclipse's Avatar
Eclipse Eclipse is offline
Coding Addict
 
Join Date: May 2004
Location: Long Island, New York
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
Try something like:
PHP Code:

if($date_c === ""){

echo(
"Error...");
}
else{
//your code here

or set it up as a POST hidden variable from the referer if you can as:
PHP Code:

$date_c $_POST["date_c"];

if(!isset(
$date_c)){
echo(
"error");
}
else{
//your code here


Last edited by Eclipse; 09-01-04 at 04:58 PM. Reason: alternite coding
Reply With Quote
  #6 (permalink)  
Old 09-01-04, 05:28 PM
Andy1984's Avatar
Andy1984 Andy1984 is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by eq1987
It's possible, but I unfortuneately can't remember the command. Ill look on php.net, but hopefully someone else can help.

There may be an easier way, depending on how you get the 2 dates. Is one input by a user?
this what your talking about:
http://www.php.net/manual/en/function.date.php
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display all dates between two date dhzen JavaScript 0 07-21-04 11:53 PM
News script with expiration dates todds Script Requests 2 03-20-04 03:53 PM
PEAR array days between two dates Dr-Leech PHP 2 03-16-04 10:41 AM
registration of prodid,name,and 2 dates pr. month ropey PHP 3 01-31-04 01:12 PM
how to compare dates in MS Access skchakri ASP 2 10-12-03 06:13 PM


All times are GMT -5. The time now is 04:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.