Re: [PHP] PHP/MySQL -- Date/Time Confusion

2002-07-12 Thread Anas Mughal


The easiest and my preferred way is to use "strtotim" method.
This method accepts MySQL format "2002-12-23" and converts it into a UNIX time stamp.
After that you can use the date function to format time as you wish!
 
  Monty <[EMAIL PROTECTED]> wrote: Which method is the best way to store date/time in 
MySQL and then which PHP
command is the best to use to convert that date to something useful? I'm
having a difficult time figuring out how to reconcile the date in MySQL so
it works with PHP's various date commands, like getdate().

Any suggestions? I'll mostly need to compared dates/times of different
records and then extract parts of the date for displaying on the screen.

Thanks!

Monty



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



-
Do You Yahoo!?
New! SBC Yahoo! Dial - 1st Month Free & unlimited access


RE: [PHP] PHP/MySQL -- Date/Time Confusion

2002-07-12 Thread David Freeman


 > Which method is the best way to store date/time in MySQL and 
 > then which PHP
 > command is the best to use to convert that date to something 
 > useful?

Get comfortable with MySQL's date functionality and you'll find that you
don't often need to do the date comparisons and manipulation in php at
all.

MySQL lets you store date/time stuff as date, time or timestamp formats
(off-hand, haven't referred to the manual here) that will store the data
for you.  You can manipulate this date information in your sql query
using things like DATE_FORMAT() and the like.  Check the MySQL manual
for all of those (chapter 6 or 7 I think it is).

If you're mostly doing data extraction based on date criteria then
you'll find it works best as sql queries basically.

CYA, Dave




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




Re: [PHP] PHP/MySQL -- Date/Time Confusion

2002-07-12 Thread 1LT John W. Holmes

You've got all kinds of options. I suggest you do any date calculations in
the database and use DATE_FORMAT to format any dates pulled out. It's
exactly like the date() function in PHP. MySQL has some great date and time
functions so you can select out exactly what you want. You can use the
UNIXTIME() (I think that's the function) function, too, to convert the MySQL
timestamp to a unix timestamp. It's all in the MySQL manual, chapter 6, Date
and Time Functions.

---John Holmes...

- Original Message -
From: "Monty" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 12, 2002 5:06 PM
Subject: [PHP] PHP/MySQL -- Date/Time Confusion


> Which method is the best way to store date/time in MySQL and then which
PHP
> command is the best to use to convert that date to something useful? I'm
> having a difficult time figuring out how to reconcile the date in MySQL so
> it works with PHP's various date commands, like getdate().
>
> Any suggestions? I'll mostly need to compared dates/times of different
> records and then extract parts of the date for displaying on the screen.
>
> Thanks!
>
> Monty
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




[PHP] PHP/MySQL -- Date/Time Confusion

2002-07-12 Thread Monty

Which method is the best way to store date/time in MySQL and then which PHP
command is the best to use to convert that date to something useful? I'm
having a difficult time figuring out how to reconcile the date in MySQL so
it works with PHP's various date commands, like getdate().

Any suggestions? I'll mostly need to compared dates/times of different
records and then extract parts of the date for displaying on the screen.

Thanks!

Monty



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