Jump to content


Photo

[solved]date diffrence.


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 August 2006 - 08:33 AM

Can somone kindly show me how to show the date left from the below i get a 2 thats wrong lol......

advance thank you.
<?php
$days_left= date("d-m-y",$record['exspire_date']) - date("d-m-y",$record['added_date']);
?>

added date: 26-08-06 // date format
exspire date: 28-07-07//date format

days left 2// from above verable

tried this way aswell.
<?php
$days_left=$record['exspire_date']-$record['added_date'];
$days_left=date("d-m-y",$days_left);

result but wrong total days left: 03-12-70
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 August 2006 - 08:58 AM

sorry i want to cleair the above post up, i need to now how many days there are from now to exspire date in a number format.

example

you have 400 days left before account exspired

example but i get a 1
<?php
$days_left=count(date("d-m-y",$record['exspire_date']));
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 26 August 2006 - 09:06 AM

If $record['exspire_date'] is held as a timestamp value
$seconds = $record['exspire_date'] - time();

$days_remaining = floor($seconds / 86400);

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 August 2006 - 09:14 AM

barand thank you so much.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users