It is currently Sat Feb 04, 2012 3:49 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Date auto calculation
PostPosted: Fri Feb 08, 2008 10:23 pm 
Offline

Joined: Fri Aug 17, 2007 6:44 pm
Posts: 3
Location: Lebanon-Beirut
Hello.

Ive just rgistered in this site, honestly its really great and helpfull, in meanwhile iam coding a php script that will enter a form post into MYSQL table predefined fields in a way of the following:


Post date:
-------------
$day=date(d);
$month=date(m);
$year=date(y);

$count = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$fulldate = "$count,$month,$year";


- The upper code will be entered in mysql table field as follows: 29,02,08
- Now the main interesting part is that how i can, for example to calculate + 3 days begin from the given day, ive try the following with no luck.

$expire=$fulldate+3;

The following giving me if the post date is 29, then expire date: 32,02,08 since February is 29 days. So all i need is how i can do in order of if the post date is 29 it jump automatically to March 3

Any code example help would be fine and thankful to my email: kegham@protechzone.com. In case this post not in its required section sorry for it. :roll:


Top
 Profile  
 
 Post subject: Date calculation solved !
PostPosted: Mon Feb 11, 2008 10:22 pm 
Offline

Joined: Fri Aug 17, 2007 6:44 pm
Posts: 3
Location: Lebanon-Beirut
Recently in my previous above post I’ve asked for a small date calculation help and i couldn’t get any answer for it, but in meanwhile i was trying to self help myself since there is always logic and mind in human :oops: . So I’ve end with the following code and i wish this will be helpful if someone need to "add days to current date" See below code and i hope it will be useful for someone :).

<?php
$hours='504'; // add hours - "504" mean ( 21 days * 24 hours )
$day=date(d); //current date
$month=date(m); // current month
$year=date(y); // current year
echo date("d-m-y", mktime($hours, 0, 0, $month, $day, $year)); // (504 = 21days)
// In this way we echo output: The current date as timestamp (day-month-year) + 504 hours this mean + 21 days, so it will automatically generate the next month and the additional days and wont generate as 32.
?>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 12, 2008 3:59 am 
Offline

Joined: Sun May 02, 2004 11:34 pm
Posts: 6498
Location: toronto, canada
Code:
echo date("d-m-y", mktime(0, 0, 0, $month, $day+21, $year));

_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron