Re: [PHP] format date field

2007-05-24 Thread Richard Lynch
On Wed, May 23, 2007 11:45 am, Mike Ryan wrote:
 I am reading in a date field from a mysql database the field on the
 screen
 shows up as 2007-05-01  on the screen I would like the field to show
 05-01-2007  currently I am issueing the following command  print
 $row['open']; how can I format this field???

 while I am at it how can I accept the date field as 05-01-2007;

http://dev.mysql.com/

Search date_format will answer the first one.

The seocnd is probably a configurable setting at mysql startup, but
I'd be leery of altering that...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] format date field

2007-05-23 Thread Mike Ryan
I am reading in a date field from a mysql database the field on the screen
shows up as 2007-05-01  on the screen I would like the field to show
05-01-2007  currently I am issueing the following command  print
$row['open']; how can I format this field???

while I am at it how can I accept the date field as 05-01-2007;

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



Re: [PHP] format date field

2007-05-23 Thread Greg Donald

On 5/23/07, Mike Ryan [EMAIL PROTECTED] wrote:

I am reading in a date field from a mysql database the field on the screen
shows up as 2007-05-01  on the screen I would like the field to show
05-01-2007  currently I am issueing the following command  print
$row['open']; how can I format this field???

while I am at it how can I accept the date field as 05-01-2007;



Look at MySQL's DATE_FORMAT() function.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] format date field

2007-05-23 Thread Kevin Murphy
Leave the date as is, its a MySQL thing. To format it on your page,  
use the date function:


$formattedDate = date(m-d-Y,strtotime($row[open]));

http://us2.php.net/manual/en/function.date.php

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On May 23, 2007, at 9:45 AM, Mike Ryan wrote:

I am reading in a date field from a mysql database the field on the  
screen

shows up as 2007-05-01  on the screen I would like the field to show
05-01-2007  currently I am issueing the following command  print
$row['open']; how can I format this field???

while I am at it how can I accept the date field as 05-01-2007;

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





[PHP] Format Date

2002-11-07 Thread dark rotter
Hi,


When i print a date, the format of this date is: 8 nov
2001 0:00
(print ($array[date]))

but i need print this: 08/11/2001

how i print this ?



ass.: Augusto Flavio



__
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

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




Re: [PHP] Format Date

2002-11-07 Thread 1LT John W. Holmes
 When i print a date, the format of this date is: 8 nov
 2001 0:00
 (print ($array[date]))
 
 but i need print this: 08/11/2001
 
 how i print this ?

Hmmm... well I want to say RTFM, but in light of the recent posts... :)

Take a look at the date() function. 

www.php.net/date

You can format your date with that. 

---John Holmes...

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




Re: [PHP] Format Date

2002-11-07 Thread Marek Kilimajer
you can do date('d/m/Y',strtotime($array['date'])), or better would be 
to change
the format at the source

dark rotter wrote:

Hi,


When i print a date, the format of this date is: 8 nov
2001 0:00
(print ($array[date]))

but i need print this: 08/11/2001

how i print this ?



ass.: Augusto Flavio



__
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

 



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




[PHP] format date

2002-04-16 Thread Alex

I just started with php and am  trying to display a query result for a date
field as mm/dd/ instead of  mysql's  -mm-dd. I looked through some
books and found the use of DATE_FORMAT to covert the dates. Is there any
other way to format the date?

Thanks

My script looks like this:

  $month_1 = ($date_month_1);
  $day_1 = ($date_day_1);
  $year_1 = ($date_year_1);
  $month_2 = ($date_month_2);
  $day_2 = ($date_day_2);
  $year_2 = ($date_year_2);

  $query = SELECT * FROM tablename where date = '$year_1-month_1-$day_1-'
AND
date = '$year_2-$month_2-$day_2';

  $result = mysql_query($query);

  $num_results = mysql_num_rows($result);


echo pNumber of records found: .$num_results./p;

  for ($i=0; $i $num_results; $i++)
  {
 $row = mysql_fetch_array($result);

 echo pstrong.($i+1).. ID: ;
 echo ($row[id]);
 echo /strongbrFirst name: ;
 echo ($row[fname]);
 echo brLast name: ;
 echo ($row[lname]);
 echo brDate: ;
 echo ($row[date]);



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




RE: [PHP] format date

2002-04-16 Thread Steve Bradwell

Hey Alex,

I use a short function like this because the date is really just a string
you can pick it apart and re-arrange it.

function Format_Date($Date){
 return $Date =
((substr($Date,6,2)).-.(substr($Date,0,2)).-.(substr($Date,3,2)));
}

Steve.
-Original Message-
From: Alex [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 16, 2002 1:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP] format date


I just started with php and am  trying to display a query result for a date
field as mm/dd/ instead of  mysql's  -mm-dd. I looked through some
books and found the use of DATE_FORMAT to covert the dates. Is there any
other way to format the date?

Thanks

My script looks like this:

  $month_1 = ($date_month_1);
  $day_1 = ($date_day_1);
  $year_1 = ($date_year_1);
  $month_2 = ($date_month_2);
  $day_2 = ($date_day_2);
  $year_2 = ($date_year_2);

  $query = SELECT * FROM tablename where date = '$year_1-month_1-$day_1-'
AND
date = '$year_2-$month_2-$day_2';

  $result = mysql_query($query);

  $num_results = mysql_num_rows($result);


echo pNumber of records found: .$num_results./p;

  for ($i=0; $i $num_results; $i++)
  {
 $row = mysql_fetch_array($result);

 echo pstrong.($i+1).. ID: ;
 echo ($row[id]);
 echo /strongbrFirst name: ;
 echo ($row[fname]);
 echo brLast name: ;
 echo ($row[lname]);
 echo brDate: ;
 echo ($row[date]);



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




Re: [PHP] format date

2002-04-16 Thread Robert Cummings


Change your query, mySQL provides some powerful formatting functions for
doing exactly what you want:


SELECT id,
   fname,
   lname,
   DATE_FORMAT( date, '%m/%d/%Y' )

FROM   tablename where date = '$year_1-month_1-$day_1-'
   AND
   date = '$year_2-$month_2-$day_2';

Cheers,
Rob.
---

Steve Bradwell wrote:
 
 Hey Alex,
 
 I use a short function like this because the date is really just a string
 you can pick it apart and re-arrange it.
 
 function Format_Date($Date){
  return $Date =
 ((substr($Date,6,2)).-.(substr($Date,0,2)).-.(substr($Date,3,2)));
 }
 
 Steve.
 -Original Message-
 From: Alex [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 16, 2002 1:36 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] format date
 
 I just started with php and am  trying to display a query result for a date
 field as mm/dd/ instead of  mysql's  -mm-dd. I looked through some
 books and found the use of DATE_FORMAT to covert the dates. Is there any
 other way to format the date?
 
 Thanks
 
 My script looks like this:
 
   $month_1 = ($date_month_1);
   $day_1 = ($date_day_1);
   $year_1 = ($date_year_1);
   $month_2 = ($date_month_2);
   $day_2 = ($date_day_2);
   $year_2 = ($date_year_2);
 
   $query = SELECT * FROM tablename where date = '$year_1-month_1-$day_1-'
 AND
 date = '$year_2-$month_2-$day_2';
 
   $result = mysql_query($query);
 
   $num_results = mysql_num_rows($result);
 
 echo pNumber of records found: .$num_results./p;
 
   for ($i=0; $i $num_results; $i++)
   {
  $row = mysql_fetch_array($result);
 
  echo pstrong.($i+1).. ID: ;
  echo ($row[id]);
  echo /strongbrFirst name: ;
  echo ($row[fname]);
  echo brLast name: ;
  echo ($row[lname]);
  echo brDate: ;
  echo ($row[date]);
 
 --
 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

-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

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




Re: [PHP] format date

2002-04-16 Thread Erik Price


On Tuesday, April 16, 2002, at 01:35  PM, Alex wrote:

 I just started with php and am  trying to display a query result for a 
 date
 field as mm/dd/ instead of  mysql's  -mm-dd. I looked through 
 some
 books and found the use of DATE_FORMAT to covert the dates. Is there any
 other way to format the date?

 Thanks

 My script looks like this:

   $month_1 = ($date_month_1);
   $day_1 = ($date_day_1);
   $year_1 = ($date_year_1);
   $month_2 = ($date_month_2);
   $day_2 = ($date_day_2);
   $year_2 = ($date_year_2);

   $query = SELECT * FROM tablename where date = 
 '$year_1-month_1-$day_1-'
 AND
 date = '$year_2-$month_2-$day_2';

As a recent convert from my own custom date-formatting techniques (can 
you believe I was storing my dates in VARCHAR(14) columns?) to the 
standards of MySQL's DATE_FORMAT function, I can't really recommend this 
approach.  Why not just take your variables and format them into a 
single string?  It'll be much, much simpler once you get used to it

// your date data in variables:
   $month_1 = ($date_month_1);
   $day_1 = ($date_day_1);
   $year_1 = ($date_year_1);
   $month_2 = ($date_month_2);
   $day_2 = ($date_day_2);
   $year_2 = ($date_year_2);

// create a timestamp representing the date data
   $timestamp_1 = mktime(0, 0, 0, $month_1, $day_1, $year_1);
   $timestamp_2 = mktime(0, 0, 0, $month_2, $day_2, $year_2);

// format the timestamps into the format preferred by MySQL's
// DATE column type
   $timestamp_1 = date('Ymd', $timestamp_1);
   $timestamp_2 = date('Ymd', $timestamp_2);

// your new and improved, and much cleaner query
   $query = SELECT *
 FROM   tablename
 WHERE  date = '$timestamp_1'
 ANDdate = '$timestamp_2'
;


It may seem like more work, but it's much neater, and you have these 
portable timestamps that can always be reformatted to whatever format 
you like for display.  (Also, be sure to use either DATE_FORMAT or 
UNIX_TIMESTAMP in MySQL queries to pull the data out in a desired 
format!  Much better than running string functions on the date result 
after the fact.)


Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] format date

2001-10-23 Thread Caleb Carvalho

Thanks,

I am inserting into table
values('$product','$title,'$date')

the date field gets added by default, like time stamp,

when i view the contents added to database i see date field showing
ex:

display.php

$product, $title,   $date

mango good fruit  Jan 1 1900 12:00:00:000AM
.

I would like the date to show  23-10-01 instead of
Jan 1 1900 12:00:00:000AM that gets inserted as a default

any help

Caleb Carvalho
Application Engineer
LoadRunner/APM
-
Enterprise Testing and Performance Management Solutions
-
Mercury Interactive
410 Frimley Business Park
Frimley, Surrey.  GU16 7ST
United Kingdom
Telephone :  +44 (0)1276 808300



From: David Robley [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: Caleb Carvalho [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: [PHP] format date
Date: Tue, 23 Oct 2001 10:02:26 +0930

On Mon, 22 Oct 2001 22:38, Caleb Carvalho wrote:
  Hi all,
 
  i would like a simple way to get date field formatted from my little
  sybase,
 
  for some reason the output of it is showing the wrong date
  example Jan 1 1900 12:00:00:000AM
 
  thanks

Perhaps if you could show what you are doing and which is not working,
someone might be able to help you. As it is we have no idea of the format
of your data or the method you are using.

--
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA

Politics is the entertainment branch of industry.


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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

2001-10-23 Thread Andrey Hristov

I don't know if this will help but there's from_unixtime() function in mysql. 
use values($some,$another,from_unixtime(.
time().),..


On Tuesday 23 October 2001 03:52 am, you wrote:
 Thanks,

 I am inserting into table
 values('$product','$title,'$date')

 the date field gets added by default, like time stamp,

 when i view the contents added to database i see date field showing
 ex:

 display.php

 $product, $title,   $date
 
 mango good fruit  Jan 1 1900 12:00:00:000AM
 .

 I would like the date to show  23-10-01 instead of
 Jan 1 1900 12:00:00:000AM that gets inserted as a default

 any help

 Caleb Carvalho
 Application Engineer
 LoadRunner/APM
 ---
-- Enterprise Testing and Performance Management Solutions
 ---
-- Mercury Interactive
 410 Frimley Business Park
 Frimley, Surrey.  GU16 7ST
 United Kingdom
 Telephone :  +44 (0)1276 808300



 From: David Robley [EMAIL PROTECTED]

 Reply-To: [EMAIL PROTECTED]
 To: Caleb Carvalho [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: Re: [PHP] format date
 Date: Tue, 23 Oct 2001 10:02:26 +0930
 
 On Mon, 22 Oct 2001 22:38, Caleb Carvalho wrote:
   Hi all,
  
   i would like a simple way to get date field formatted from my little
   sybase,
  
   for some reason the output of it is showing the wrong date
   example Jan 1 1900 12:00:00:000AM
  
   thanks
 
 Perhaps if you could show what you are doing and which is not working,
 someone might be able to help you. As it is we have no idea of the format
 of your data or the method you are using.
 
 --
 David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
 CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA
 
 Politics is the entertainment branch of industry.

 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

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

2001-10-23 Thread Mark Roedel

 -Original Message-
 From: Caleb Carvalho [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, October 23, 2001 2:53 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP] format date
 
 
 I am inserting into table
 values('$product','$title,'$date')
 
 the date field gets added by default, like time stamp,

Does $date have a value at this point?  What is it?
 
 when i view the contents added to database i see date field showing
 ex:
 
 display.php
 
 $product, $title,   $date
 
 mango good fruit  Jan 1 1900 12:00:00:000AM

This looks to me suspiciously like Sybase is seeing either an empty/zero
value or one that it's not able to parse as a date and time.  Are you
*sure* that the column type you're using is supposed to automagically
insert a current timestamp?  If so, you might double-check your
documentation to see under what circumstances it will do so...it might
only do it, for example, if you insert a NULL value (which is not the
same as an empty string).  If not, you could try using the now()
function in your insert query instead of specifying a '$date' value.


---
Mark Roedel |  Blessed is he who has learned to laugh
Systems Programmer  |   at himself, for he shall never cease
LeTourneau University   |   to be entertained.
Longview, Texas, USA|   -- John Powell 

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




FW: [PHP] format date

2001-10-23 Thread Mark Roedel

 -Original Message-
 From: Caleb Carvalho [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, October 23, 2001 2:53 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP] format date
 
 
 I am inserting into table
 values('$product','$title,'$date')
 
 the date field gets added by default, like time stamp,

Does $date have a value at this point?  What is it?
 
 when i view the contents added to database i see date field showing
 ex:
 
 display.php
 
 $product, $title,   $date
 
 mango good fruit  Jan 1 1900 12:00:00:000AM

This looks to me suspiciously like Sybase is seeing either an empty/zero
value or one that it's not able to parse as a date and time.  Are you
*sure* that the column type you're using is supposed to automagically
insert a current timestamp?  If so, you might double-check your
documentation to see under what circumstances it will do so...it might
only do it, for example, if you insert a NULL value (which is not the
same as an empty string).  If not, you could try using the now()
function in your insert query instead of specifying a '$date' value.


---
Mark Roedel |  Blessed is he who has learned to laugh
Systems Programmer  |   at himself, for he shall never cease
LeTourneau University   |   to be entertained.
Longview, Texas, USA|   -- John Powell 
 

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

2001-10-22 Thread Caleb Carvalho

Hi all,

i would like a simple way to get date field formatted from my little sybase,

for some reason the output of it is showing the wrong date
example Jan 1 1900 12:00:00:000AM

thanks

Caleb Carvalho
Application Engineer
LoadRunner/APM
-
Enterprise Testing and Performance Management Solutions
-
Mercury Interactive
410 Frimley Business Park
Frimley, Surrey.  GU16 7ST
United Kingdom
Telephone :  +44 (0)1276 808300


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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

2001-10-22 Thread David Robley

On Mon, 22 Oct 2001 22:38, Caleb Carvalho wrote:
 Hi all,

 i would like a simple way to get date field formatted from my little
 sybase,

 for some reason the output of it is showing the wrong date
 example Jan 1 1900 12:00:00:000AM

 thanks

Perhaps if you could show what you are doing and which is not working, 
someone might be able to help you. As it is we have no idea of the format 
of your data or the method you are using.

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   Politics is the entertainment branch of industry.

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