PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



Date auto calculation

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> MySQL General
View previous topic :: View next topic  
Author Message
kegham



Joined: 17 Aug 2007
Posts: 3
Location: Lebanon-Beirut

PostPosted: Fri Feb 08, 2008 9:23 pm    Post subject: Date auto calculation Reply with quote

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. Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
kegham



Joined: 17 Aug 2007
Posts: 3
Location: Lebanon-Beirut

PostPosted: Mon Feb 11, 2008 9:22 pm    Post subject: Date calculation solved ! Reply with quote

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 Embarassed . 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 Smile.

<?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.
?>
Back to top
View user's profile Send private message Visit poster's website
lostboy



Joined: 02 May 2004
Posts: 5128
Location: toronto, canada

PostPosted: Tue Feb 12, 2008 2:59 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



PHP Code Examples
 Stream diffrent sizes of images from a single image to save disk space.
 JavaScript dropdown list menu to switch any page.
 Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
 PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside.
 Link Extractor - This function is used to extract links from a given URL. This will convert relative path into absolute path and also remove PHPSESSID stuff.
 Building a Dynamic Form using Javascript and innerHTML. Add form elements in realtime without refreshing the page.
 A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Post new topic   Reply to topic    WeberForums.com Forum Index -> MySQL General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum






Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum