Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
how i add the days in the date
Old 10-07-2004, 09:43 AM how i add the days in the date
faisalzafar's Avatar
Experienced Talker

Posts: 41
Location: Pakistan
Trades: 0
hi dear i want to add the days in the date

e.g date is 2004-05-23
and i want to add 10 days in that

how can i add that tell me plz

Your suggestions are highly appreciated

Thanx bye

Faisal Zafar
__________________
[COLOR=Pink]Faisal Zafar[/COLOR]
faisalzafar is offline
Reply With Quote
View Public Profile Visit faisalzafar's homepage!
 
 
Register now for full access!
Old 10-07-2004, 11:48 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
PHP Code:
<?php
echo date('Y-m-d');

$month date('m');
$day date('d');
$year date('Y');

echo 
'<br />';

echo 
$year '-';
echo 
$month '-';
echo 
$day 10;
?>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 10-07-2004, 02:48 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
If it's a textual date (ie: you have a string "2004-05-23" that you want to add 10 days to), then it's easiest to parse the textual date into a timestamp with strtotime(), then add ten days.

PHP Code:
$mydate "2004-05-23";
$newdate strtotime($mydate);
$newdate $newdate + (60 60 24 10);
echo 
date('y-m-d'$newdate); 
You can just use time() (or mktime() if you want a predefined date) to just get a timestamp isntead of parsing a textual date:

PHP Code:
$newdate time(); // right now
$newdate $newdate + (60 60 24 10);
echo 
date('y-m-d'$newdate); 
cptnwinky, your method would not always work. For example, if it was the 26th of a month, the date would end up being the 36th etc.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 10-07-2004, 03:16 PM
compmodder26's Avatar
Experienced Talker

Posts: 44
Trades: 0
You could just do:

PHP Code:
$datevar "2004-05-23";
$exploded explode("-"$datevar);
$day $exploded[2] + 10;
$new date $exploded[0]."-".$exploded[1]."-".$day
__________________
Buy Cool Univeristy of Kentucky Merchandise at

Please login or register to view this content. Registration is FREE
compmodder26 is offline
Reply With Quote
View Public Profile Visit compmodder26's homepage!
 
Old 10-07-2004, 03:34 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
That is basically the same thing cptnwinky did. If you add 10 to 23, you get 33. There is no 33rd of any month.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to how i add the days in the date
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.78912 seconds with 12 queries