Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-06 Thread DL Neil

Hi Andy
I apologise. The way I wrote the suggestion looks very much like a SQL
query doesn't it? It wasn't!
It would have been better expressed if I had said:

retrieve the MySQL timestamp field as a UNIX (epoch) timestamp, by using
the UNIX_TIMESTAMP function within the SELECT statement

 I tryed:
 $stmt= 
 SELECT first_name,  user_logindate , password
 FROM  $T5
 using UNIX_TIMESTAMP()
 WHERE user_id = '$user_id'
 LIMIT 1
 ;

 But is is returning an error.

 Do u know where the syntax error is? As I did understand u right...
first
 select with this kind of statement, then format it with date(xxx,
 $timestamp)

So to 'repair the damage', please try:

$stmt= 
SELECT first_name,  UNIX_TIMESTAMP( user_logindate ) AS login, password
FROM  $T5
WHERE user_id = '$user_id'
LIMIT 1
;

Manual reference: 6.3.4 Date and Time Functions

The 'login' value, once fetched from the resultset, may then be fed to
PHP's DATE() (date function - see earlier msg below, manual reference
http://www.php.net/manual/en/function.date.php) and presented in any
suitably user-friendly format.

Ok now?
=dn


  So what is the proper function in PHP to convert the MySQL timestamp
 into a
  proper format like Sonday, Apr. 20th 2002?

 SELECT from SQL using UNIX_TIMESTAMP()

 Format for presentation in PHP using: string date ( string format [,
int
 timestamp])

 Regards,
 =dn


I am playing around with the timestamp functions. I created a
 timestamp
with mysql ( the row is timestamp)
and do reformat this thing after selecting with php in the
 folowíng way:
   
 $date_posted[$i] = strftime(%A, %d-%m-%Y %R,
$date_posted[$i]);
   
This always returns Tuesday, 19-01-2038 but the mysql timestamp
 says:
20020305211704
  
   They return the time in different formats. Read the MySQL manual
 then read
   the PHP manual (or vice-versa).
  
   The MySQL timestamp is human readable. So in your example above:
  
   20020305211704 == 2002-03-05 21:17:04
  
   time() in PHP is the number of seconds since the Unix Epoch.


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




[PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-05 Thread Andy

Hi there,

I am playing around with the timestamp functions I created a timestamp with
mysql ( the row is timestamp)
and do reformat this thing after selecting with php in the folowíng way:

 $date_posted[$i] = strftime(%A, %d-%m-%Y %R, $date_posted[$i]);

This always returns Tuesday, 19-01-2038 but the mysql timestamp says:
20020305211704

So whats going on?

Can anybody help please?

Thanx andy



-- 
PHP General Mailing List (http://wwwphpnet/)
To unsubscribe, visit: http://wwwphpnet/unsubphp




Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-05 Thread Jason Wong

On Wednesday 06 March 2002 04:31, Andy wrote:
 Hi there,

 I am playing around with the timestamp functions. I created a timestamp
 with mysql ( the row is timestamp)
 and do reformat this thing after selecting with php in the folowíng way:

  $date_posted[$i] = strftime(%A, %d-%m-%Y %R, $date_posted[$i]);

 This always returns Tuesday, 19-01-2038 but the mysql timestamp says:
 20020305211704

They return the time in different formats. Read the MySQL manual then read 
the PHP manual (or vice-versa).

The MySQL timestamp is human readable. So in your example above:

20020305211704 == 2002-03-05 21:17:04

time() in PHP is the number of seconds since the Unix Epoch.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
But, officer, he's not drunk, I just saw his fingers twitch!
*/

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




Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-05 Thread Mike Eheler

The long way, but it will help in the understanding of it:

$timestamp = 20020305211704;
$year = substr($timestamp, 0, 4);
$month = substr($timestamp, 4, 2);
$day = substr($timestamp, 6, 2);
$hour = substr($timestamp, 8, 2);
$minute = substr($timestamp, 10, 2);
$second = substr($timestamp, 12, 2);
$utime = mktime($hour, $minute, $second, $month, $day, $year);
$longdate = date('l, F jS, Y @ g:i:sp');

echo $longdate;

Will produce:

Tuesday, March 5th, 2002 @ 9:17:04pm

Mike

Andy wrote:
 So what is the proper function in PHP to convert the MySQL timestamp into a
 proper format like Sonday, Apr. 20th 2002?
 
 Thanx,
 
  Andy
 
 
 Jason Wong [EMAIL PROTECTED] schrieb im Newsbeitrag
 news:[EMAIL PROTECTED]...
 
On Wednesday 06 March 2002 04:31, Andy wrote:

Hi there,

I am playing around with the timestamp functions. I created a timestamp
with mysql ( the row is timestamp)
and do reformat this thing after selecting with php in the folowíng way:

 $date_posted[$i] = strftime(%A, %d-%m-%Y %R, $date_posted[$i]);

This always returns Tuesday, 19-01-2038 but the mysql timestamp says:
20020305211704

They return the time in different formats. Read the MySQL manual then read
the PHP manual (or vice-versa).

The MySQL timestamp is human readable. So in your example above:

20020305211704 == 2002-03-05 21:17:04

time() in PHP is the number of seconds since the Unix Epoch.

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
But, officer, he's not drunk, I just saw his fingers twitch!
*/

 
 



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




Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-05 Thread Andy

So what is the proper function in PHP to convert the MySQL timestamp into a
proper format like Sonday, Apr. 20th 2002?

Thanx,

 Andy


Jason Wong [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED];
 On Wednesday 06 March 2002 04:31, Andy wrote:
  Hi there,
 
  I am playing around with the timestamp functions. I created a timestamp
  with mysql ( the row is timestamp)
  and do reformat this thing after selecting with php in the folowíng way:
 
   $date_posted[$i] = strftime(%A, %d-%m-%Y %R, $date_posted[$i]);
 
  This always returns Tuesday, 19-01-2038 but the mysql timestamp says:
  20020305211704

 They return the time in different formats. Read the MySQL manual then read
 the PHP manual (or vice-versa).

 The MySQL timestamp is human readable. So in your example above:

 20020305211704 == 2002-03-05 21:17:04

 time() in PHP is the number of seconds since the Unix Epoch.

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 But, officer, he's not drunk, I just saw his fingers twitch!
 */



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




Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-05 Thread DL Neil

Andy,

 So what is the proper function in PHP to convert the MySQL timestamp
into a
 proper format like Sonday, Apr. 20th 2002?

SELECT from SQL using UNIX_TIMESTAMP()

Format for presentation in PHP using: string date ( string format [, int
timestamp])

Regards,
=dn


   I am playing around with the timestamp functions. I created a
timestamp
   with mysql ( the row is timestamp)
   and do reformat this thing after selecting with php in the
folowíng way:
  
$date_posted[$i] = strftime(%A, %d-%m-%Y %R, $date_posted[$i]);
  
   This always returns Tuesday, 19-01-2038 but the mysql timestamp
says:
   20020305211704
 
  They return the time in different formats. Read the MySQL manual
then read
  the PHP manual (or vice-versa).
 
  The MySQL timestamp is human readable. So in your example above:
 
  20020305211704 == 2002-03-05 21:17:04
 
  time() in PHP is the number of seconds since the Unix Epoch.


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




[PHP] Re: [PHP-DB] Re: [PHP] timestamp iin MySQL not compatible to the one in PHP???

2002-03-05 Thread Ken Thompson

On Tuesday 05 March 2002 05:11 pm, Andy wrote:
 So what is the proper function in PHP to convert the MySQL timestamp into a
 proper format like Sonday, Apr. 20th 2002?

?php
echo date(D. M. d, Y)
?

 Thanx,

  Andy


 Jason Wong [EMAIL PROTECTED] schrieb im Newsbeitrag
 news:[EMAIL PROTECTED]...

  On Wednesday 06 March 2002 04:31, Andy wrote:
   Hi there,
  
   I am playing around with the timestamp functions. I created a timestamp
   with mysql ( the row is timestamp)
   and do reformat this thing after selecting with php in the folowíng
   way:
  
$date_posted[$i] = strftime(%A, %d-%m-%Y %R, $date_posted[$i]);
  
   This always returns Tuesday, 19-01-2038 but the mysql timestamp says:
   20020305211704
 
  They return the time in different formats. Read the MySQL manual then
  read the PHP manual (or vice-versa).
 
  The MySQL timestamp is human readable. So in your example above:
 
  20020305211704 == 2002-03-05 21:17:04
 
  time() in PHP is the number of seconds since the Unix Epoch.
 
  --
  Jason Wong - Gremlins Associates - www.gremlins.com.hk
 
  /*
  But, officer, he's not drunk, I just saw his fingers twitch!
  */

-- 


Ken Thompson, North West Antique Autos
Payette, Idaho
Email: [EMAIL PROTECTED]
http://www.nwaa.com
Sales and brokering of antique autos and parts.

Linux- Coming Soon To A Desktop Near You
Registered Linux User #183936

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