[PHP] Re: time stamp screwing up

2003-01-06 Thread Scott Fletcher
Instead of the php function, 'time()'.  Try 'date()'.  Somethine like this

--clip--
?
//Long way around
date(Y).-.date(m).-.date(d);

//Shortcut
date(Y-m-d);
?
--clip--

You can customize the way you want the time format to be displayed.  You can
find it at http://www.php.net/manual/en/function.date.php and you'll see the
option for dates and times.

- - [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hey guys could someone help me
 I have created a user login register system in  flash with PHP and Mysql.
 Everthing Now works fine aprt from the time stamp of when the user
 registered.

 Code ---
 // Get current date  time
 $time = time();
 // Connects to the Database.
 $Connect = mysql_connect($dbServer, $dbUser, $dbPass);
 mysql_select_db($dbName);
 // Preforms the SQL query to see if user name already exsists
 $query = SELECT name FROM contacts WHERE name='$name';
 $rs_contacts = mysql_query($query) or die(mysql_error());
 $row = mysql_fetch_assoc($rs_contacts);
 if ($row[name] == $name) {
 print loginT=UserName in Usechecklog=2;
 }else{
 $query = INSERT INTO contacts (id, name, pass, email, dateAdded) VALUES
 (NULL, '$name', '$pass', '$email', '$time');
 }


 It inserts -00-00
 instead of the current date

 ideas

 P.S
 I am a newbie try keeping reponse's simple please





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




[PHP] Re: time stamp

2002-08-28 Thread David Robley

In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] says...
 I am using PHP with MySQL and have a timestamp field in my db table.  What 
 would be the easiest way to get the newest timestamp out of the db?
 
 Thanks in Advance
 Steve

Use an ORDER BY on the timestamp field in your select statement, and use 
LIMIT to restrict the number of rows you retrieve (if you want a subset of 
rows).


-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




[PHP] RE: time stamp

2002-08-28 Thread Lopez David E-r9374c

Steve

Try: SELECT MAX(field_timestamp) from table1;

David

 -Original Message-
 From: Steve Buehler [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, August 27, 2002 5:21 PM
 To: mysql; PHP
 Subject: time stamp
 
 
 I am using PHP with MySQL and have a timestamp field in my db 
 table.  What 
 would be the easiest way to get the newest timestamp out of the db?
 
 Thanks in Advance
 Steve
 
 
 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.
 ow3
 
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail 
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 

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




[PHP] RE: time stamp

2002-08-28 Thread Steve Buehler

Thank you David Lopez and David Robley.  That was what I was looking 
for.  Here is how I used it.

$date=getlastupdatetime(array(team_id = $team_id,
 season = $season,
 div_id = $div_id));
echo $date;

function getlastupdatetime($a){
 extract($a);
 $result=mysql_query (SELECT MAX(UNIX_TIMESTAMP(updated)) as 
epoch_time FROM games
 WHERE (hteam='$team_id' OR vteam='$team_id')
 AND sea_id = '$season' AND div_id = 
'$div_id');
 $date = mysql_result ($result, 0, 0);
 if(!$date){
 return;
 }else{
 return date(l dS of F Y h:i:s A O,$date);
 }
}


Which gives me the following line:
Wednesday 28th of August 2002 06:00:06 PM -0500

I was doing the following which was a bit more code and I wanted to use a 
little less code.  Plus it should make the search and processing quicker.

$date=getlastupdatetime(array(team_id = $team_id,
 season = $season,
 div_id = $div_id));
echo $date;

function getlastupdatetime($a){
 extract($a);
 $result=mysql_query(SELECT updated FROM games WHERE 
(hteam='$team_id' OR vteam='$team_id')
 AND sea_id = '$season' AND 
div_id = '$div_id');
 $b=0;
 while(($row=mysql_fetch_object($result))){
 if($row-updated  $b){
 $b=$row-updated;
 }
 }
 $date=$b;
 $year=substr($date,0,4);
 $month=substr($date,4,2);
 $day=substr($date,6,2);
 $hour=substr($date,8,2);
 $min=substr($date,10,2);
 if($hour = 12){$ap = pm;}else{$ap = am;}
 if($hour  12){$hour = $hour-12;}
 if(!$month){
 return nothing;
 }else{
 return $month-$day-$year $hour:$min $apbr;
 }
*/
}


Thank Again
Steve


At 08:28 AM 8/28/2002 -0700, you wrote:
Steve

Try: SELECT MAX(field_timestamp) from table1;

David

  -Original Message-
  From: Steve Buehler [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, August 27, 2002 5:21 PM
  To: mysql; PHP
  Subject: time stamp
 
 
  I am using PHP with MySQL and have a timestamp field in my db
  table.  What
  would be the easiest way to get the newest timestamp out of the db?
 
  Thanks in Advance
  Steve
 
 
  --
  This message has been scanned for viruses and
  dangerous content by MailScanner, and is
  believed to be clean.
  ow3
 
 
  -
  Before posting, please check:
 http://www.mysql.com/manual.php  (the manual)
 http://lists.mysql.com/  (the list archive)
 
  To request this thread, e-mail [EMAIL PROTECTED]
  To unsubscribe, e-mail
  [EMAIL PROTECTED]
  Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3



--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3


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