By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

calculate date

P: 5
I am the new programmer. I have encounter with the problem to calculate the date auto beacuse I has been assign to develop library system for my final project...How I can automatik calculte the date borrow for two weeks..
Jan 8 '08 #1
Share this Question
Share on Google+
7 Replies


nathj
Expert 100+
P: 938
I am the new programmer. I have encounter with the problem to calculate the date auto beacuse I has been assign to develop library system for my final project...How I can automatik calculte the date borrow for two weeks..

Hi,

I would check out the PHP date functions first.These are pretty powerful. If you wanted to figure out the date 14 dyas from now you could do something like:
[php]
$lcNowPlus14 = mktime(0, 0, 0, date("m") , date("d")+14, date("Y"));
$lcDateString = date('l jS F Y', $lcNowPlus14) ;
echo $lcDateString
[/php]
This will output something like:
Expand|Select|Wrap|Line Numbers
  1. Tuesday 22nd January 2008
  2.  
Using the various formatting options php has with the date function means you should be able to get the format you want.

Cheers
nathj
Jan 8 '08 #2

P: 5
Hi,

I would check out the PHP date functions first.These are pretty powerful. If you wanted to figure out the date 14 dyas from now you could do something like:
[php]
$lcNowPlus14 = mktime(0, 0, 0, date("m") , date("d")+14, date("Y"));
$lcDateString = date('l jS F Y', $lcNowPlus14) ;
echo $lcDateString
[/php]
This will output something like:
Expand|Select|Wrap|Line Numbers
  1. Tuesday 22nd January 2008
  2.  
Using the various formatting options php has with the date function means you should be able to get the format you want.

Cheers
nathj

thank you my fwen...
I'm really appreciate it...
it helps me more...
Jan 9 '08 #3

nathj
Expert 100+
P: 938
thank you my fwen...
I'm really appreciate it...
it helps me more...
Hi,

I'm glad to have helped you out. If you nede any more help juust post back.

Cheers
nathj
Jan 9 '08 #4

P: 5
I have a new prob...how to convert date format in my sql yyyy-mm-dd to dd-mm-yyyy....so easy for me to make calculation
Jan 11 '08 #5

nathj
Expert 100+
P: 938
I have a new prob...how to convert date format in my sql yyyy-mm-dd to dd-mm-yyyy....so easy for me to make calculation
Hi,

Take a look at the MySQL date functions particulalry date_format.

You could use this to format the date as you retreive it from the database so that you get the format you want.

I hope this helps
nathj
Jan 11 '08 #6

P: 5
Hi,

Take a look at the MySQL date functions particulalry date_format.

You could use this to format the date as you retreive it from the database so that you get the format you want.

I hope this helps
nathj
Thankz buddy....it makes me one day to understand the coding seriously....
Jan 14 '08 #7

P: 5
could anyone help me solve this problem

<?php
// init values
$datefrom = 'due_Date';
$dateto = 'return_Date';
// convert dots to hyphens
$datefrom = str_replace('.','-', $datefrom);
$dateto = str_replace('.','-', $dateto);
// calc to seconds
$datefrom = strtotime($datefrom, 0);
$dateto = strtotime($dateto, 0);
// calc difference in seconds
$difference = $dateto - $datefrom;
// reformat to days
$datediff = floor($difference / 86400);
// print result
print "<b>$datediff</b>";
?>

the result should print the total day late submitted by the borrower but the answer given still 0 even the day late is 1....please...
Jan 15 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.