[PHP-DB] timestamp problem

2004-11-18 Thread Doug Parker
I'm trying to format a MySQL Timestamp Column Type with PHP, and it's not
going well.  In reading up on it, I see that the idea is to convert the
Timestamp type to Unix format using the strtotime() function, then using the
date() function to format that result.  However, this only appears to work
with MySQL versions above 4.1 - where the Timestamp has been modified to
have the : symbol in between the approprate numbers, as opposed to the
traditional extended format (i.e. 20041117104300), which can be found on
Mysql versions 4.0xx and below.  I have  MySQL 4.1 on my local machine, but
MySQL 4.0 something on the box I'm publishing to - which is obviously the
more important box.  So I need to get it working using the regular format.
And I don't want to just parse the characters because I have a bunch of
timestamp columns and don't really think it's that great of a resolution.

Any ideas?

thanks...

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



RE: [PHP-DB] timestamp problem

2004-11-18 Thread Bastien Koert
this is a common mysql timestamp problem, you can try using 
DATE_FORMAT(datefield, FORMAT) sql function to define the date, or store the 
timestamp as a unix timestamp (an integer) from the get go

bastien
From: Doug Parker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] timestamp problem
Date: Thu, 18 Nov 2004 10:46:53 -0800
I'm trying to format a MySQL Timestamp Column Type with PHP, and it's not
going well.  In reading up on it, I see that the idea is to convert the
Timestamp type to Unix format using the strtotime() function, then using 
the
date() function to format that result.  However, this only appears to work
with MySQL versions above 4.1 - where the Timestamp has been modified to
have the : symbol in between the approprate numbers, as opposed to the
traditional extended format (i.e. 20041117104300), which can be found on
Mysql versions 4.0xx and below.  I have  MySQL 4.1 on my local machine, 
but
MySQL 4.0 something on the box I'm publishing to - which is obviously the
more important box.  So I need to get it working using the regular format.
And I don't want to just parse the characters because I have a bunch of
timestamp columns and don't really think it's that great of a resolution.

Any ideas?
thanks...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] timestamp problem

2004-11-18 Thread Rodrigo Cabeceiras
Hi 
Does it help?



function time_stp(){
$curdate=getdate(time());
echo $curdate[weekday].  .$curdate[mday]. .$curdate[month].
.$curdate[year];
echo BR;
echo $curdate[hours].:.$curdate[minutes].:.$curdate[seconds];

}
function quiet_time_stp_data(){
$curdate=getdate(time());
$data_func=$curdate[year].- .$curdate[mon].- .$curdate[mday] ;
return $data_func;

}
function quiet_time_stp_hora(){
$curdate=getdate(time());
$hora_func =
$curdate[hours].:.$curdate[minutes].:.$curdate[seconds];
return $hora_func;

}

Rodrigo


---
Rodrigo Cabeceiras
-
Rua do Ameal nº 507 5º Esq
4200-061 Porto
-
Tel.:917776045
msn: [EMAIL PROTECTED]
-
web: www.rodrigocabeceiras.pt.to
 
-

-Mensagem original-
De: Doug Parker [mailto:[EMAIL PROTECTED] 
Enviada: quinta-feira, 18 de Novembro de 2004 18:47
Para: [EMAIL PROTECTED]
Assunto: [PHP-DB] timestamp problem

I'm trying to format a MySQL Timestamp Column Type with PHP, and it's not
going well.  In reading up on it, I see that the idea is to convert the
Timestamp type to Unix format using the strtotime() function, then using the
date() function to format that result.  However, this only appears to work
with MySQL versions above 4.1 - where the Timestamp has been modified to
have the : symbol in between the approprate numbers, as opposed to the
traditional extended format (i.e. 20041117104300), which can be found on
Mysql versions 4.0xx and below.  I have  MySQL 4.1 on my local machine, but
MySQL 4.0 something on the box I'm publishing to - which is obviously the
more important box.  So I need to get it working using the regular format.
And I don't want to just parse the characters because I have a bunch of
timestamp columns and don't really think it's that great of a resolution.

Any ideas?

thanks...

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

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



Re: [PHP-DB] timestamp problem

2004-11-18 Thread John Holmes
Doug Parker wrote:
I'm trying to format a MySQL Timestamp Column Type with PHP, and it's not
going well.  In reading up on it, I see that the idea is to convert the
Timestamp type to Unix format using the strtotime() function, then using the
date() function to format that result.  However, this only appears to work
with MySQL versions above 4.1 - where the Timestamp has been modified to
have the : symbol in between the approprate numbers, as opposed to the
traditional extended format (i.e. 20041117104300), which can be found on
Mysql versions 4.0xx and below.  I have  MySQL 4.1 on my local machine, but
MySQL 4.0 something on the box I'm publishing to - which is obviously the
more important box.  So I need to get it working using the regular format.
And I don't want to just parse the characters because I have a bunch of
timestamp columns and don't really think it's that great of a resolution.
Use DATE_FORMAT() in your query to format the timestamp, TO_UNIXTIME() 
to retrieve a unix timestamp instead of a MySQL timestamp in your query, 
or use a couple substr() calls to pull out the pieces of the MySQL 
timestamp you need and then pass them to mktime().

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] timestamp problem

2004-11-18 Thread Doug Parker
Ok, thanks for the input.  I knew that was an option as well, the problem is
that I have about eight different dates in the query, and I'd rather do a
query like SELECT projects.* FROM projects... and then format those
results, rather than do SELECT DATE_FORMAT('%m %d %Y', projects.Date1) AS
Date1, DATE_FORMAT('%m %d %Y', projects.Date2) AS Date2,... etc

any other suggestions?

John Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Doug Parker wrote:
  I'm trying to format a MySQL Timestamp Column Type with PHP, and it's
not
  going well.  In reading up on it, I see that the idea is to convert the
  Timestamp type to Unix format using the strtotime() function, then using
the
  date() function to format that result.  However, this only appears to
work
  with MySQL versions above 4.1 - where the Timestamp has been modified to
  have the : symbol in between the approprate numbers, as opposed to the
  traditional extended format (i.e. 20041117104300), which can be found on
  Mysql versions 4.0xx and below.  I have  MySQL 4.1 on my local machine,
but
  MySQL 4.0 something on the box I'm publishing to - which is obviously
the
  more important box.  So I need to get it working using the regular
format.
  And I don't want to just parse the characters because I have a bunch of
  timestamp columns and don't really think it's that great of a
resolution.

 Use DATE_FORMAT() in your query to format the timestamp, TO_UNIXTIME()
 to retrieve a unix timestamp instead of a MySQL timestamp in your query,
 or use a couple substr() calls to pull out the pieces of the MySQL
 timestamp you need and then pass them to mktime().

 --

 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 php|architect: The Magazine for PHP Professionals – www.phparch.com

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



[PHP-DB] timestamp problem

2003-03-13 Thread drparker
I'm using the timestamp column type in a database, and the only problem
is that it the stamp is three hours prior to the actual post when I post
to a remote server.  I'm assuming, since it works fine on my machine,
that this is because the remote server I am is in a different time
zone.  Is there any way I can amend my code to account for the time
difference?


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



RE: [PHP-DB] timestamp problem

2003-03-13 Thread John W. Holmes
 I'm using the timestamp column type in a database, and the only
problem
 is that it the stamp is three hours prior to the actual post when I
post
 to a remote server.  I'm assuming, since it works fine on my machine,
 that this is because the remote server I am is in a different time
 zone.  Is there any way I can amend my code to account for the time
 difference?

So adjust it. Either add 3 hours to any time you add to the database or
when you pull the time from the database... You can use mktime() in PHP
or DATE_ADD() in (assuming) MySQL. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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