[PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?

2002-01-13 Thread Sander Peters

Hello everybody,

convert /mm/dd to mm/dd/, how?

MYSQL does everything in /mm/dd.
I live in the Netherlands and we are use to the format dd/mm/.

What's the best way to display it as mm/dd/ in a table on a query?

My first idea whas to split the date up in vars in php and then print
the vars in the way I like it
Is this a bad idea? Or are there better sollutions?

Thanx in advance for answering!



--
Met vriendelijke groet / With Greetings,

Sander Peters

   site: http://www.visionnet.nl/
  email: mailto:[EMAIL PROTECTED]
webmail: mailto:[EMAIL PROTECTED]



-- 
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]




Re: [PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?

2002-01-13 Thread Jonathan David Edwin Wright

Hiya,

Personally, I use the following bit of code. All it does is take a 14 digit 
timestamp and convert it into a unix timestamp:

function date($date) {
   //Extract the parts from the date
   $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);
   $sec   = substr($date, 10, 2);
   //return the unix timestamp for the date passed
   return (gmmktime($hour, $min, $sec, $month, $day, $year));
}

 From then on, you can use the date function in PHP to manage the date. 
There are also ways to do it using the SQL command (DATE_FORMATE() I think 
is one), but you'll have to read the manual for into on that.

At 20:56 13/01/2002 +0100, Sander Peters wrote:
Hello everybody,

convert /mm/dd to mm/dd/, how?

MYSQL does everything in /mm/dd.
I live in the Netherlands and we are use to the format dd/mm/.

What's the best way to display it as mm/dd/ in a table on a query?

My first idea whas to split the date up in vars in php and then print
the vars in the way I like it
Is this a bad idea? Or are there better sollutions?

Thanx in advance for answering!



--
Met vriendelijke groet / With Greetings,

Sander Peters

site: http://www.visionnet.nl/
   email: mailto:[EMAIL PROTECTED]
webmail: mailto:[EMAIL PROTECTED]



--
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]

// Jonathan Wright
// [EMAIL PROTECTED]
// GCS d- s: a-- C++(+) US P+++ L+ E W+++ !N w !O M- V- PS+@ PE+
//Y PGP t+ !5 X R- tv(-) b(+) DI D+(++) G h-- r-- z--(++)


-- 
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]




Re: [PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?

2002-01-13 Thread mike cullerton

on 1/13/02 12:56 PM, Sander Peters at [EMAIL PROTECTED] wrote:

 My first idea whas to split the date up in vars in php and then print
 the vars in the way I like it
 Is this a bad idea? Or are there better sollutions?

that's the way i do it. i have 2 functions i use all the time for getting
dates in and out of mysql using $month,$day,$year.

for any project, i also create functions for formatting $month,$day,$year
however the customer requires the output.

 -- mike cullerton 



-- 
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]




Re: [PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?

2002-01-13 Thread Rasmus Lerdorf

MySQL has plenty of functions to return dates to you in any format you
specify.  Please read
http://mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_functions
and pay special attention to the DATE_FORMAT() function.

-Rasmus



On Sun, 13 Jan 2002, Sander Peters wrote:

 Hello everybody,

 convert /mm/dd to mm/dd/, how?

 MYSQL does everything in /mm/dd.
 I live in the Netherlands and we are use to the format dd/mm/.

 What's the best way to display it as mm/dd/ in a table on a query?

 My first idea whas to split the date up in vars in php and then print
 the vars in the way I like it
 Is this a bad idea? Or are there better sollutions?

 Thanx in advance for answering!



 --
 Met vriendelijke groet / With Greetings,

 Sander Peters

site: http://www.visionnet.nl/
   email: mailto:[EMAIL PROTECTED]
 webmail: mailto:[EMAIL PROTECTED]



 --
 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 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] Re: [PHP-DB] Re: [PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?

2002-01-13 Thread DL Neil

Rasmus,

I have held several datetime-related conversations with people recently, and another 
series about 'when'/whether
to use PHP or MySQL functionality.

Here you are, the man of PHP, advising Sander to use MySQL functionality! (and in 
marked contrast to the
(biased) advice one might expect on PHP lists, eg JDEW's reply) I'm grinning at the 
apparent incongruity, but
with no insult to yourself.

Would you care to comment further on when one should consider using SQL commands in 
favor of implementing
identical functionality in PHP (and possibly in some situations, vice-versa)?

Regards,
=dn



- Original Message -
From: Rasmus Lerdorf [EMAIL PROTECTED]
To: Sander Peters [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: 13 January 2002 19:52
Subject: [PHP-DB] Re: [PHP] convert /mm/dd to mm/dd/, how?


 MySQL has plenty of functions to return dates to you in any format you
 specify.  Please read
 
http://mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_functions
 and pay special attention to the DATE_FORMAT() function.

 -Rasmus



 On Sun, 13 Jan 2002, Sander Peters wrote:

  Hello everybody,
 
  convert /mm/dd to mm/dd/, how?
 
  MYSQL does everything in /mm/dd.
  I live in the Netherlands and we are use to the format dd/mm/.
 
  What's the best way to display it as mm/dd/ in a table on a query?
 
  My first idea whas to split the date up in vars in php and then print
  the vars in the way I like it
  Is this a bad idea? Or are there better sollutions?
 
  Thanx in advance for answering!
 
 
 
  --
  Met vriendelijke groet / With Greetings,
 
  Sander Peters
 
 site: http://www.visionnet.nl/
email: mailto:[EMAIL PROTECTED]
  webmail: mailto:[EMAIL PROTECTED]
 
 
 
  --
  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 Database 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 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] Re: [PHP-DB] Re: [PHP] convert yyyy/mm/dd to mm/dd/yyyy, how?

2002-01-13 Thread Rasmus Lerdorf

You use the right tool for the job.  MySQL is going to have to format the
date field for the return anyway.  It makes sense to simply tell MySQL
your preferred format instead of having it returned to you in the wrong
format and then you having to apply more gear to get it into the right
one.

-Rasmus

On Sun, 13 Jan 2002, DL Neil wrote:

 Rasmus,

 I have held several datetime-related conversations with people recently, and another 
series about 'when'/whether
 to use PHP or MySQL functionality.

 Here you are, the man of PHP, advising Sander to use MySQL functionality! (and in 
marked contrast to the
 (biased) advice one might expect on PHP lists, eg JDEW's reply) I'm grinning at the 
apparent incongruity, but
 with no insult to yourself.

 Would you care to comment further on when one should consider using SQL commands in 
favor of implementing
 identical functionality in PHP (and possibly in some situations, vice-versa)?

 Regards,
 =dn



 - Original Message -
 From: Rasmus Lerdorf [EMAIL PROTECTED]
 To: Sander Peters [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: 13 January 2002 19:52
 Subject: [PHP-DB] Re: [PHP] convert /mm/dd to mm/dd/, how?


  MySQL has plenty of functions to return dates to you in any format you
  specify.  Please read
  
http://mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_functions
  and pay special attention to the DATE_FORMAT() function.
 
  -Rasmus
 
 
 
  On Sun, 13 Jan 2002, Sander Peters wrote:
 
   Hello everybody,
  
   convert /mm/dd to mm/dd/, how?
  
   MYSQL does everything in /mm/dd.
   I live in the Netherlands and we are use to the format dd/mm/.
  
   What's the best way to display it as mm/dd/ in a table on a query?
  
   My first idea whas to split the date up in vars in php and then print
   the vars in the way I like it
   Is this a bad idea? Or are there better sollutions?
  
   Thanx in advance for answering!
  
  
  
   --
   Met vriendelijke groet / With Greetings,
  
   Sander Peters
  
  site: http://www.visionnet.nl/
 email: mailto:[EMAIL PROTECTED]
   webmail: mailto:[EMAIL PROTECTED]
  
  
  
   --
   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 Database 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 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]