Re: [PHP] unix time stamp to readable date

2003-06-05 Thread Justin French
http://au.php.net/date

Justin


on 05/06/03 1:15 AM, Diana Castillo ([EMAIL PROTECTED]) wrote:

> I know this is a stupid question but I am confused,
> how do I convert a unix timestamp to a readable date with php?
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] unix time stamp to readable date

2003-06-05 Thread Diana Castillo
I know this is a stupid question but I am confused,
how do I convert a unix timestamp to a readable date with php?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unix time

2002-05-23 Thread Miguel Cruz

On Thu, 23 May 2002, Cosmin wrote:
>  How can I compare Unix Time?
>  As integer values?
>  I take the unix time from database and I compare with the current time
>  and something is not functioning. Can somebody show me how can I do this?

SELECT UNIX_TIMESTAMP(mytimestampfield) FROM table;

Not really sure where you've gone wrong because you show no code and don't
say what the problem is. "something is not functioning" doesn't give us
very much to go on.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Unix time

2002-05-23 Thread Cosmin

yes I think is ok,
I don't know why, but I used strtotime... (what do this function?)

Thank you
Cosmin


Justin French <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> It'd help if you showed us some code.
>
> If you've got a unix time stamp in your MySQL db, then all you need to do
is
> compare it to your local server time using time().
>
> Easy.
>
>  $then = "1021877476";   // your unix timestamp stored in MySQL
> $now = time();  // current time stamp
> $difference = $now - $then; // in seconds
> ?>
>
> If your date is stored in YYY-MM-DD format, you'll have to convert it to a
> unix time stamp first (can be done in query, or using strtotime()).
>
>
> Justin
>
>
>
> on 23/05/02 8:06 PM, Cosmin ([EMAIL PROTECTED]) wrote:
>
> > Hello
> >
> > How can I compare Unix Time?
> > As integer values?
> > I take the unix time from database and I compare with the current time
> > and something is not functioning. Can somebody show me how can I do
this?
> >
> > Thank you ,
> > Cosmin
> >
> >
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Unix time

2002-05-23 Thread Justin French

It'd help if you showed us some code.

If you've got a unix time stamp in your MySQL db, then all you need to do is
compare it to your local server time using time().

Easy.



If your date is stored in YYY-MM-DD format, you'll have to convert it to a
unix time stamp first (can be done in query, or using strtotime()).


Justin



on 23/05/02 8:06 PM, Cosmin ([EMAIL PROTECTED]) wrote:

> Hello
> 
> How can I compare Unix Time?
> As integer values?
> I take the unix time from database and I compare with the current time
> and something is not functioning. Can somebody show me how can I do this?
> 
> Thank you ,
> Cosmin
> 
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Unix time

2002-05-23 Thread Cosmin

 Hello

 How can I compare Unix Time?
 As integer values?
 I take the unix time from database and I compare with the current time
 and something is not functioning. Can somebody show me how can I do this?

 Thank you ,
 Cosmin





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Unix-time problem

2001-03-04 Thread Don Read


On 05-Mar-01 Nicklas af Ekenstam wrote:
> Hi!
> 
> I wrote this simple function to return the current date minus supplied 
> number of years:
> 
> function get_birthdate($age_in_years) {
>   


> You, obviously, call it like this: echo get_birthdate(1);
> Which would return a datestring that looks like this: 05/03/2000
> 
> Works nice, but the problem occurs when I try to subtract more than 31 
> years which is naturall since, as far as UNIX is concerned, the world 
> didn't exist then.
> (Took me a while to figure this one out though.)
> 
> Any clues on how to fix this so that I can go beyond the past 31 years?
> 

function get_birthdate($age_in_years) {
  list ($y,$m,$d) =explode('-', date('Y-m-d'));
  $bdstr=sprintf("%02d/%02d/%04d", $m, $d, $y - $age_in_years);
  return($bdstr);
}

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- If you are going to sin, sin against God, not the bureaucracy. 
  God will forgive you but the bureaucrats won't. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Unix-time problem

2001-03-04 Thread Nicklas af Ekenstam

Hi!

I wrote this simple function to return the current date minus supplied 
number of years:

function get_birthdate($age_in_years)   {

// get the current timestamp into an array
$timestamp =  time();
$date_time_array =  getdate($timestamp);
$hours =  $date_time_array["hours"];
$minutes =  $date_time_array["minutes"];
$seconds =  $date_time_array["seconds"];
$month =  $date_time_array["mon"];
$day =  $date_time_array["mday"];
$year =  $date_time_array["year"];

// use mktime to recreate the unix timestamp
// subtracting age_low and age_high from the years
$timestamp =  mktime($hours, $minutes,$seconds ,$month, $day,$year - 
$age_in_years);
$birthdate = strftime("%d/%m/%Y", $timestamp);

return($birthdate);
}

You, obviously, call it like this: echo get_birthdate(1);
Which would return a datestring that looks like this: 05/03/2000

Works nice, but the problem occurs when I try to subtract more than 31 
years which is naturall since, as far as UNIX is concerned, the world 
didn't exist then.
(Took me a while to figure this one out though.)

Any clues on how to fix this so that I can go beyond the past 31 years?

Sincerely,
Nicklas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]