Joined: 17 Aug 2007 Posts: 3 Location: Lebanon-Beirut
Posted: Fri Feb 08, 2008 9:23 pm Post subject: Date auto calculation
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);
- 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.
Joined: 17 Aug 2007 Posts: 3 Location: Lebanon-Beirut
Posted: Mon Feb 11, 2008 9:22 pm Post subject: Date calculation solved !
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 . 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.
?>
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