[PHP-DB] Date formatting question

2009-04-08 Thread Jack Lauman
I need to reformat the output of the 'dates' field from '2009-04-08' to 
'Wed. Apr. 8th'. Any help would be appreciated.


Thanks.

---

for ($counter = 0; $counter  mysql_num_rows($resultID); $counter++);

while ($row = mysql_fetch_object($resultID))
{
print tr;
print td . $row-dates . /td;
print td . $row-times . /td;
print td . $row-am_pm . /td;
print td . $row-height . /td;
print td . $row-cond . /td;
print /tr;
}


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



Re: [PHP-DB] Date formatting question

2009-04-08 Thread Chris

Jack Lauman wrote:
I need to reformat the output of the 'dates' field from '2009-04-08' to 
'Wed. Apr. 8th'. Any help would be appreciated.


You can either do it using mysql date formats (see 
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format) 
or something like date('...', strtotime($result-date));


See http://php.net/date and http://php.net/strtotime

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP-DB] Date formatting question

2009-04-08 Thread Phpster

See the date function

Http://www.php.net/date

Bastien

Sent from my iPod

On Apr 8, 2009, at 21:41, Jack Lauman jlau...@nwcascades.com wrote:

I need to reformat the output of the 'dates' field from '2009-04-08'  
to 'Wed. Apr. 8th'. Any help would be appreciated.


Thanks.

---

for ($counter = 0; $counter  mysql_num_rows($resultID); $counter++);

while ($row = mysql_fetch_object($resultID))
{
   print tr;
   print td . $row-dates . /td;
   print td . $row-times . /td;
   print td . $row-am_pm . /td;
   print td . $row-height . /td;
   print td . $row-cond . /td;
   print /tr;
}


--
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] Date Translation in MySQL

2008-08-10 Thread Bastien Koert
On Tue, Aug 5, 2008 at 4:33 PM, Ben Miller [EMAIL PROTECTED]wrote:

 Figured there had to be an easier way.  Thank you so much.

 -Original Message-
 From: Simcha Younger [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 05, 2008 2:48 PM
 To: php-db@lists.php.net
 Subject: RE: [PHP-DB] Date Translation in MySQL


 Select * FROM ... WHERE DAYOFWEEK(datecol)=7

 -Original Message-
 From: Ben Miller [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 05, 2008 8:10 PM
 To: PHP. DB Mail List
 Subject: [PHP-DB] Date Translation in MySQL

 I'm looking for a quick and simple way to query a MySQL database by date,
 or
 more specifically, by day of the week.  My dates are stored in the DB in
 -MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
 that will take this column and return only Saturdays, for example, without
 having to use PHP to find each of the last X number of Saturdays and then
 for each Saturday, query the database?

 In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

 Thanks in advance.



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

 No virus found in this incoming message.
 Checked by AVG - http://www.avg.com
 Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
 06:03


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


Also look at the mysql DATE_FORMAT function

-- 

Bastien

Cat, the other other white meat


[PHP-DB] Date Translation in MySQL

2008-08-05 Thread Ben Miller
I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



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



RE: [PHP-DB] Date Translation in MySQL

2008-08-05 Thread Simcha Younger
Select * FROM ... WHERE DAYOFWEEK(datecol)=7

-Original Message-
From: Ben Miller [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 05, 2008 8:10 PM
To: PHP. DB Mail List
Subject: [PHP-DB] Date Translation in MySQL

I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
06:03


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



RE: [PHP-DB] Date Translation in MySQL

2008-08-05 Thread Ben Miller
Figured there had to be an easier way.  Thank you so much.

-Original Message-
From: Simcha Younger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 2:48 PM
To: php-db@lists.php.net
Subject: RE: [PHP-DB] Date Translation in MySQL


Select * FROM ... WHERE DAYOFWEEK(datecol)=7

-Original Message-
From: Ben Miller [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 8:10 PM
To: PHP. DB Mail List
Subject: [PHP-DB] Date Translation in MySQL

I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
06:03


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



[PHP-DB] Date calculation from MySql table

2008-04-12 Thread A. Joseph
I want to calculate the registed users today
Also total users this week
Total users this month
Total users this year

The Mysql table has a row of INT(11) with time() value inserted.

I did something like this
$today = strtotime(+1 day)
Then $sql = SELECT COUNT(*) FROM table WHERE dateReg = $today;

Same with year/months also, only I use strtotime(+1 week) for a week,
strtotime(+1 month) for a month,

Can someone help me with this calculation?

On 4/7/08, Bruno Lustosa [EMAIL PROTECTED] wrote:
 On Mon, Apr 7, 2008 at 2:42 PM, Dee Ayy [EMAIL PROTECTED] wrote:
   I was thinking of using output buffering and then making 1 call to
   utf8_encode, but I think a better question is, how do I stop using
   utf8_encode completely?

 If all components are using utf-8, you should have no problems with
 charsets at all. By all components, I mean:
 - Script files in utf-8;
 - Database in utf-8;
 - Database connection using utf-8;
 - Content-type header set to utf-8.
 With all these, you're free of charset hell, and can enjoy the beauty
 of utf-8 completely without problems.

   The rendered view I see in Firefox 2.0.0.12 is a question mark ?
   where the French character should have appeared.  If I use
   utf8_encode, the character appears as it should.

 Question mark means the character is not utf-8. Check where it comes
 from. Might be the database or the way you are connecting to it. I
 don't know much about mysql, I use postgresql. With it, you just have
 to call pg_set_client_encoding() to make the connection in utf-8 mode,
 and create database with encoding='unicode' to set up a database
 using utf-8.

   Luckily I'm on PHP 4.3.10, so I can't see what mb_check_encoding would
   report -- if that would even help normally.

 Shouls upgrade to PHP 5. PHP 4 is way out of date, is not getting
 updates anymore, and will not even get security bugfixes after august
 8th. It's been almost 4 years since PHP 5 was released.

 http://www.php.net/archive/2007.php

 Check the PHP 4 end of life announcement.

 --
 Bruno Lustosa [EMAIL PROTECTED]
 ZCE - Zend Certified Engineer - PHP!
 http://www.lustosa.net/

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




-- 
I develop dynamic website with PHP  MySql, Let me know about your site

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



Re: [PHP-DB] Date calculation from MySql table

2008-04-12 Thread Evert Lammerts

Something like this should work.

$today = mktime(0, 0, 0, date(m), date(d), date(Y));
$tomorrow = mktime(0, 0, 0, date(m), date(d) + 1, date(Y));
$sql = SELECT COUNT(*) FROM table WHERE regdate BETWEEN {$today} AND 
{$tomorrow};


$thismonth = mktime(0, 0, 0, date(m), 1, date(Y));
$nextmonth = mktime(0, 0, 0, date(m) + 1, 1, date(Y));
$sql = SELECT COUNT(*) FROM table WHERE regdate BETWEEN {$thismonth} 
AND {$nextmonth};


$thisyear = mktime(0, 0, 0, 1, 1, date(Y));
$nextyear = mktime(0, 0, 0, 1, 1, date(Y) + 1);
$sql = SELECT COUNT(*) FROM table WHERE regdate BETWEEN {$thisyear} AND 
{$nextyear};


HOWEVER, consider to use the mysql date functions instead of a unix 
timestamp.


A. Joseph wrote:

I want to calculate the registed users today
Also total users this week
Total users this month
Total users this year

The Mysql table has a row of INT(11) with time() value inserted.

I did something like this
$today = strtotime(+1 day)
Then $sql = SELECT COUNT(*) FROM table WHERE dateReg = $today;

Same with year/months also, only I use strtotime(+1 week) for a week,
strtotime(+1 month) for a month,

Can someone help me with this calculation?

On 4/7/08, Bruno Lustosa [EMAIL PROTECTED] wrote:
  

On Mon, Apr 7, 2008 at 2:42 PM, Dee Ayy [EMAIL PROTECTED] wrote:


 I was thinking of using output buffering and then making 1 call to
 utf8_encode, but I think a better question is, how do I stop using
 utf8_encode completely?
  

If all components are using utf-8, you should have no problems with
charsets at all. By all components, I mean:
- Script files in utf-8;
- Database in utf-8;
- Database connection using utf-8;
- Content-type header set to utf-8.
With all these, you're free of charset hell, and can enjoy the beauty
of utf-8 completely without problems.



 The rendered view I see in Firefox 2.0.0.12 is a question mark ?
 where the French character should have appeared.  If I use
 utf8_encode, the character appears as it should.
  

Question mark means the character is not utf-8. Check where it comes
from. Might be the database or the way you are connecting to it. I
don't know much about mysql, I use postgresql. With it, you just have
to call pg_set_client_encoding() to make the connection in utf-8 mode,
and create database with encoding='unicode' to set up a database
using utf-8.



 Luckily I'm on PHP 4.3.10, so I can't see what mb_check_encoding would
 report -- if that would even help normally.
  

Shouls upgrade to PHP 5. PHP 4 is way out of date, is not getting
updates anymore, and will not even get security bugfixes after august
8th. It's been almost 4 years since PHP 5 was released.

http://www.php.net/archive/2007.php

Check the PHP 4 end of life announcement.

--
Bruno Lustosa [EMAIL PROTECTED]
ZCE - Zend Certified Engineer - PHP!
http://www.lustosa.net/

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



[PHP-DB] date format problem

2007-12-22 Thread arafat uddin
my problem  is with date format

mysql support  -mm-dd

but my client not use to enter date in -mm-dd  format
he use to in  dd-mm-yyy   format

how can it possible to input date in
dd-mm- format


RE: [PHP-DB] date format problem

2007-12-22 Thread Bastien Koert

www.php.net/date will show you all the possibilities of formatting the date

bastien

 Date: Sat, 22 Dec 2007 17:54:07 +0600
 From: [EMAIL PROTECTED]
 To: php-db@lists.php.net
 Subject: [PHP-DB] date format problem
 
 my problem  is with date format
 
 mysql support  -mm-dd
 
 but my client not use to enter date in -mm-dd  format
 he use to in  dd-mm-yyy   format
 
 how can it possible to input date in
 dd-mm- format

_
Use fowl language with Chicktionary. Click here to start playing!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-07 Thread Instruct ICC

From: rDubya [EMAIL PROTECTED]

Thanks for the help so far guys!!

Not helping though.  I have the date contained in the database as timestamp
(-MM-DD HH:MM:SS).


Do you really need to pull events from the database which are not in your 
range of interest?  This will only slow down your processing time.  Instead, 
you could be looping over valid events and not using your incorrect 
check_date function.


If you insist upon using a check_date function on the PHP side (which you 
claimed to have worked in the past), on the format -MM-DD HH:MM:SS where 
the first Y is at index 0, then substr($mysql_timestamp, 4, 2) is not the 
month MM, it is -M.  You need 5,2.  Your other offsets are also wrong.  
Rather than debugging your check_date function, you should just pull the 
info you actually need from the database (even to the point of not selecting 
*, and instead naming specific fields if you really don't need all fields), 
and remove your check_date function.  Then your while loop will loop over 
only valid events.


Also, although this doesn't affect the running of your code, your variable 
names show a misunderstanding of what parameters you are passing and 
receiving.


$sql = SELECT...;
$resultResource = mysql_query($sql);// or just $result = mysql_query($sql);
if($result != false){
  while($event_data = mysql_fetch_assoc($result)) {
 //Do something with a valid event instead of checking if it is valid 
now on the PHP side.

  }
}

Too bad you are not on MySQL 5, because the SQL query could have been even 
closer to the phrasing you posted to the list it is between now and three 
weeks from now, similar to Mike's reply as:

$sql = SELECT * FROM `EVENTS`
WHERE `event_city` = ' . $city . '
AND `theEventDate` BETWEEN NOW() AND DATE_ADD( NOW(), INTERVAL 3 WEEK)
ORDER BY `theEventDate` ASC;

But for your MySQL version, WEEK is unavailable and you need INTERVAL 21 DAY
(watch the unit versus the expr; DAY not DAYS -- WEEK not WEEKS)
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_date-add
http://dev.mysql.com/doc/refman/4.1/en/comparison-operators.html

But if you are not familiar with BETWEEN or DATE_ADD, then the way I posted 
is another way to skin this cat.


$sql = SELECT * FROM `EVENTS`
WHERE `event_city` = ' . $city . '
AND TO_DAYS( `theEventDate` ) = TO_DAYS( NOW() )
AND TO_DAYS( `theEventDate` ) = TO_DAYS( NOW() ) + 21
ORDER BY `theEventDate` ASC;

http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_to-days

And while not trusting your indexing, rewrite short_date as:
function short_date ($mysql_timestamp) {
   return date(D M j, $mysql_timestamp);
}

or this is probably a 1-liner in the while loop:
while...//I'm already using valid events due to my query
  ... date(D M j, $event_data['theEventDate']) ...

_
Test your celebrity IQ.  Play Red Carpet Reveal and earn great prizes! 
http://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_hotmailtextlink2


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



Re: [PHP-DB] date problems

2007-09-07 Thread Instruct ICC

From: Instruct ICC [EMAIL PROTECTED]
And while not trusting your indexing, rewrite short_date as:
My short_date rewrite was also wrong.  So it looks like you will have to 
learn those offsets for this function if you do it on the PHP side.  But you 
could also do it on the MySQL side.


_
Get a FREE small business Web site and more from Microsoft® Office Live! 
http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/


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



Re: [PHP-DB] date problems

2007-09-07 Thread Graham Cossey
This DID work, but I recently switched hosting companies...

Is the new server in a different country with a different date format
/ time zone?

Just a thought  ;-\

On 9/7/07, Instruct ICC [EMAIL PROTECTED] wrote:
 From: Instruct ICC [EMAIL PROTECTED]
 And while not trusting your indexing, rewrite short_date as:
 My short_date rewrite was also wrong.  So it looks like you will have to
 learn those offsets for this function if you do it on the PHP side.  But you
 could also do it on the MySQL side.

 _
 Get a FREE small business Web site and more from Microsoft(r) Office Live!
 http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/

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




-- 
Graham

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



Re: [PHP-DB] date problems

2007-09-07 Thread rDubya
WOW!!  Thanks for all the help guys!!  And Instruct ICC.. you're
solution for pulling the events did work.. but..  it turns out that
the solution was actually much simpler than I thought:

The old mysql database (once again, not sure what version) stored the
date as MMDDHHMMSS.  The new database stores the date as
-MM-DD HH:MM:SS.  All I had to do was adjust my code to pull only
the values and none of the delimeters (ie. -,  , and :).
DUH!!!

But once again, thanks you guys for all the help


rDubya


On 9/7/07, Instruct ICC [EMAIL PROTECTED] wrote:
 From: Instruct ICC [EMAIL PROTECTED]
 And while not trusting your indexing, rewrite short_date as:
 My short_date rewrite was also wrong.  So it looks like you will have to
 learn those offsets for this function if you do it on the PHP side.  But you
 could also do it on the MySQL side.

 _
 Get a FREE small business Web site and more from Microsoft(r) Office Live!
 http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/

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



[PHP-DB] date problems

2007-09-06 Thread rDubya
I'm having a problem with dates in php and mysql.  I run a site that
promotes dated events and concerts and has the information for each
stored in a mysql database with the timestamp field.

Here is the function that checks the date of the event to ensure it is
between now and three weeks from now (only events in this time period
are displayed on a page, with all events being displayed on another
page)

function check_date ($mysql_timestamp, $days) {

$timestamp = mktime(0, 0, 0, substr($mysql_timestamp, 4, 2),
substr($mysql_timestamp, 6, 2), substr($mysql_timestamp, 0, 4));
$event_day = date(z, $timestamp);
$event_year = date(Y, $timestamp);
$actual_day = date(z);
$actual_year =  date(Y);

while ($event_year  $actual_year) {
$event_day = $event_day + 365;
$event_year--;
}

if (($event_day - $actual_day) = $days  $event_day =
$actual_day) { return TRUE; }

else { return FALSE; }
}


Then, to display the events that fill this criteria, there is this
code for the date:

function short_date ($mysql_timestamp) {
$stimestamp = mktime(0, 0, 0, substr($mysql_timestamp, 4, 2),
substr($mysql_timestamp, 6, 2), substr($mysql_timestamp, 0, 4));
$sformatted_date = date(D M j, $stimestamp);
return $sformatted_date;
}


My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya

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



RE: [PHP-DB] date problems

2007-09-06 Thread Instruct ICC

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days

_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us


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



Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us




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



Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
Argh, make sure you add the closing paren for the date_add since I 
forgot it.


Mike...

Mike Gohlke wrote:
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya [EMAIL PROTECTED]
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us






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



Re: [PHP-DB] date problems

2007-09-06 Thread rDubya
Thanks for the help so far guys!!

Not helping though.  I have the date contained in the database as timestamp
(-MM-DD HH:MM:SS).  The problem is that not only is it not displaying
events, but if I alter my code so that it displays ALL events, it shows the
events for the last year, and those upcoming, as all being in the first
couple weeks of December, 2006.

Here is the script in action: http://www.clubandpub.ca/lobby/?city=1

The events SHOULD display on the right column, under where it says events.
If you click to the GUIDE page, the calendar should be highlighted on the
dates where there are events, and the events in the coming weeks (as well as
concerts) should display below that (under their respective headings).

This DID work, but I recently switched hosting companies as the one I was
with has become increasingly unreliable after the company changed hands.  My
new server uses PHP 5 server, with MySQL 4.1 (I'm not 100% sure what the old
was.. I think it was PHP 4, and while I think it was the same MySQL version,
it could have been an earlier one).

Cheers!

rDubya

also, here is the code that actually displays the events:

?php

$db = mysql_connect(xx, user, pw) or error(mysql_error);
mysql_select_db(database, $db) or error(mysql_error);

$eventquery = mysql_query(SELECT * FROM `EVENTS` WHERE `event_city` =
'$city' ORDER BY `date` ASC, $db);

while($event_data = mysql_fetch_assoc($eventquery)) {

if (check_date($event_data[date], 21) == TRUE) {
?


it then displays the event information of the events within that time period
(pulled from the database, with the date being displayed using the
short_date function posted earlier)





On 9/6/07, Mike Gohlke [EMAIL PROTECTED] wrote:

 Argh, make sure you add the closing paren for the date_add since I
 forgot it.

 Mike...

 Mike Gohlke wrote:
  It's much better to use add_date instead of to_days since mysql isn't
  smart enough to do it for you.
  Such as:
  SELECT yourEventFields FROM theTable
  WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;
 
  This way mysql will calc the now() and date_add and will essentially
  convert them to static values.  If there's an index on theEventDate it
  will be used.
 
  Mike...
 
  Instruct ICC wrote:
  From: rDubya [EMAIL PROTECTED]
  My problem is that I have events dated for Sep 2007 and on, and yet
  they all come up as being on Dec 7 to 9, 2006..  any ideas?
 
  rDubya
 
  How about having MySQL only return the events you are interested in?
 
  SELECT yourEventFields FROM theTable
  WHERE
  TO_DAYS( theEventDate ) = TO_DAYS( NOW() )
  AND
  TO_DAYS( theEventDate ) = TO_DAYS( NOW() ) + 21
 
  I like theEventDate to be in the format -MM-DD
 
 
 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days
 
 
  _
  A place for moms to take a break!
  http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us
 
 

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




[PHP-DB] DATE

2007-04-06 Thread Ron Piggott
Would someone help me with this ---

How do I get the results for 2 days before Easter Sunday from this ---
what do I have to do to my date statement to figure out Good Friday?

$good_Friday = date(Y-m-d, easter_date($current_year));


Re: [PHP-DB] Date problem

2007-01-21 Thread Miles Thompson

At 12:26 PM 1/21/2007, Denis L. Menezes wrote:


Dear friends.

I have a date field in mysql called event_end .

I want to run a query to find all records where the event_and is greater
than today's date. I have written the following code. It does not work.
Please point out the mistake.

$today = getdate();
 $sql=select * from events where event_end'.$today.' order by event_start
Asc ;


Thanks
denis


How is your date formatted in the database.

Compare  that to the format returned by getdate(), then consider using 
date('Y-m-d'). That's assuming your MySQL date is stored as -mm-dd.


Nonetheless, this should set you on the right road.

It would also have helped your diagnosis if you echoed your SQL statement.

Cheers - Miles Thompson




--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.410 / Virus Database: 268.17.3/642 - Release Date: 1/20/2007

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



[PHP-DB] Date Conversion in RFC822 format

2006-05-18 Thread Manoj Singh

Hello all,

I am developing a site in php implementing the concept of rss feeds. For
that i want to convert the standard date into RFC822 format.

If any one have idea about it, please help me.

Regards
Manoj


Re: [PHP-DB] Date Conversion in RFC822 format

2006-05-18 Thread Stut

Manoj Singh wrote:

I am developing a site in php implementing the concept of rss feeds. For
that i want to convert the standard date into RFC822 format.

If any one have idea about it, please help me.


Go to http://php.net/date and search the page for RFC822. If you need 
further help read the rest of that page.


-Stut

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



[PHP-DB] Date Conversion

2006-05-16 Thread Mark Bomgardner

PHP 4.4/MySQL 4.0

I am tying to convert a date to put into a database from a string (ie: 
January, February) to a numeric value (ie: 01,02).  I am taking the 
value from a form, which is a drop down menu listing the months.


$sMonth1 = $_POST['Smonth']; returns the money selected from the form.
When I go to format the month from a string to numeric with 
date('m',strtotime($sMonth1));

it returns 12, no matter which month I select.

In reading the docs at php.net, date('m',strtotime($sMonth1)); is 
correct to reformat from a string to a time format.


What am I missing.


mark bomgardner

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



RE: [PHP-DB] Date Conversion

2006-05-16 Thread Ralph Brickley
A simple associate array would work as well, although not quite as elegent.
$months_arr = array(January=01, February=02...);

-Original Message-
From: Mark Bomgardner [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 12:35 PM
To: Php-Db
Subject: [PHP-DB] Date Conversion

PHP 4.4/MySQL 4.0

I am tying to convert a date to put into a database from a string (ie: 
January, February) to a numeric value (ie: 01,02).  I am taking the 
value from a form, which is a drop down menu listing the months.

$sMonth1 = $_POST['Smonth']; returns the money selected from the form.
When I go to format the month from a string to numeric with 
date('m',strtotime($sMonth1));
it returns 12, no matter which month I select.

In reading the docs at php.net, date('m',strtotime($sMonth1)); is 
correct to reformat from a string to a time format.

What am I missing.


mark bomgardner

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

2006-05-16 Thread Ralph Brickley
ADDENDUM:

To Convert your date string, use the associate array:
$months_arr = array(January=01, February
=02...);

$month = $months_arr[February];

* Replace $months_arr[February] with $_POST[Month];

// Output
$month = 01;



Ralph Brickley

-Original Message-
From: Ralph Brickley [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 1:29 PM
To: [EMAIL PROTECTED]; 'Php-Db'
Subject: RE: [PHP-DB] Date Conversion

A simple associate array would work as well, although not quite as elegent.
$months_arr = array(January=01, February=02...);

-Original Message-
From: Mark Bomgardner [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 12:35 PM
To: Php-Db
Subject: [PHP-DB] Date Conversion

PHP 4.4/MySQL 4.0

I am tying to convert a date to put into a database from a string (ie: 
January, February) to a numeric value (ie: 01,02).  I am taking the 
value from a form, which is a drop down menu listing the months.

$sMonth1 = $_POST['Smonth']; returns the money selected from the form.
When I go to format the month from a string to numeric with 
date('m',strtotime($sMonth1));
it returns 12, no matter which month I select.

In reading the docs at php.net, date('m',strtotime($sMonth1)); is 
correct to reformat from a string to a time format.

What am I missing.


mark bomgardner

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

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



Re: [PHP-DB] Date question

2006-03-17 Thread Gerry Danen
This works perfect, Bastien!

Many thanks.

Gerry

On 3/13/06, Bastien Koert [EMAIL PROTECTED] wrote:

 select * from table where date_format(date_field, '%Y-%m') = '2006-02'


 bastien


 From: Gerry Danen [EMAIL PROTECTED]
 To: php-db@lists.php.net
 CC: [EMAIL PROTECTED]
 Subject: [PHP-DB] Date question
 Date: Sun, 12 Mar 2006 20:44:13 -0700
 
 While I am rebuilding my crashed laptop (the machine that had all my
 intelligence), I started thinking about a select statement I need.
 
 I have log info in a table and want to extract it on a monthly basis. The
 date field is in -mm-dd format. What's a good way to select those
 dates
 that match 2006-02, for example.
 
 I apologize if the solution should be staring me in the face, but all my
 favorites and help files are toast, until I can restore some of them.



RE: [PHP-DB] Date question

2006-03-13 Thread Bastien Koert

select * from table where date_format(date_field, '%Y-%m') = '2006-02'


bastien



From: Gerry Danen [EMAIL PROTECTED]
To: php-db@lists.php.net
CC: [EMAIL PROTECTED]
Subject: [PHP-DB] Date question
Date: Sun, 12 Mar 2006 20:44:13 -0700

While I am rebuilding my crashed laptop (the machine that had all my
intelligence), I started thinking about a select statement I need.

I have log info in a table and want to extract it on a monthly basis. The
date field is in -mm-dd format. What's a good way to select those dates
that match 2006-02, for example.

I apologize if the solution should be staring me in the face, but all my
favorites and help files are toast, until I can restore some of them.

TIA.

Gerry


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



[PHP-DB] Date question

2006-03-12 Thread Gerry Danen
While I am rebuilding my crashed laptop (the machine that had all my
intelligence), I started thinking about a select statement I need.

I have log info in a table and want to extract it on a monthly basis. The
date field is in -mm-dd format. What's a good way to select those dates
that match 2006-02, for example.

I apologize if the solution should be staring me in the face, but all my
favorites and help files are toast, until I can restore some of them.

TIA.

Gerry


Re: [PHP-DB] Date question

2006-03-12 Thread LJ Regalado
For example, you have table `logs` with `datelog` field and you want to
select dates
that match 2006-02. You can try this select statement:

SELECT * FROM `logs` WHERE MONTH(datelog)='02' and YEAR(datelog)='2006'

Hope that helps.

LJ Regalado


Re: [PHP-DB] Date question

2006-03-12 Thread Chris

Gerry Danen wrote:

While I am rebuilding my crashed laptop (the machine that had all my
intelligence), I started thinking about a select statement I need.

I have log info in a table and want to extract it on a monthly basis. The
date field is in -mm-dd format. What's a good way to select those dates
that match 2006-02, for example.

I apologize if the solution should be staring me in the face, but all my
favorites and help files are toast, until I can restore some of them.


Which database are you using?

Mysql has this: 
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html


Postgresql has:
http://www.postgresql.org/docs/8.1/static/functions-datetime.html

I'm sure others have the same sort of functionality.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP-DB] Date Time 90 minutes ago

2006-01-19 Thread Ron Piggott (PHP)
Would someone be able to help me with the DATE command syntax to know
what the date and time was 90 minutes ago?  I am trying to assign these
values into two variables:

$date_90_minutes_ago
$time_90_minutes_ago

I am not sure how to handle midnight where if the time is 00:10:00
ninety minutes earlier is a day before.  Thanks.  Ron

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



RE: [PHP-DB] Date Time 90 minutes ago

2006-01-19 Thread Bastien Koert

?php
echo date(Y-m-d H:i:s,strtotime(90 minutes ago));
?

bastien



From: Ron Piggott (PHP) [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Date  Time 90 minutes ago
Date: Thu, 19 Jan 2006 16:57:33 -0500

Would someone be able to help me with the DATE command syntax to know
what the date and time was 90 minutes ago?  I am trying to assign these
values into two variables:

$date_90_minutes_ago
$time_90_minutes_ago

I am not sure how to handle midnight where if the time is 00:10:00
ninety minutes earlier is a day before.  Thanks.  Ron

--
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] Date Time 90 minutes ago

2006-01-19 Thread Cal Evans

$date_90_minutes_ago = date('m/d/Y',mktime()-(60*90));
$time_90_minutes_ago = date('h:i:s',mktime()-(60*90));

60 seconds * 90 minutes.
=C=
|
| Cal Evans
| http://www.calevans.com
|
| We get our best customers from referrals.
| We would appreciate you referring any of your
| friends or co-workers that need web hosting.
|
|

Ron Piggott (PHP) wrote:

Would someone be able to help me with the DATE command syntax to know
what the date and time was 90 minutes ago?  I am trying to assign these
values into two variables:

$date_90_minutes_ago
$time_90_minutes_ago

I am not sure how to handle midnight where if the time is 00:10:00
ninety minutes earlier is a day before.  Thanks.  Ron



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



RE: [PHP-DB] Date Time 90 minutes ago

2006-01-19 Thread tg-php
Bastien's example is probably the quickest and easiest.  I just wanted to point 
out that you can use math within the mktime() function as well in case the 
relative date/time you need isn't right now.

$month = 1;
$day = 19;
$year = 2006;
$hour = 17;
$minute = 08;
$second = 05;

echo date(Y-m-d H:i:s, mktime($hour, $minute - 90, $second, $month, $day, 
$year));

It will even adjust for leap years I believe.  You can add/subtract/etc any of 
those items and it's smart enough to figure out what the correct resulting 
date/time would be.

-TG


= = = Original message = = =

?php
echo date(Y-m-d H:i:s,strtotime(90 minutes ago));
?

bastien


From: Ron Piggott (PHP) [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] Date  Time 90 minutes ago
Date: Thu, 19 Jan 2006 16:57:33 -0500

Would someone be able to help me with the DATE command syntax to know
what the date and time was 90 minutes ago?  I am trying to assign these
values into two variables:

$date_90_minutes_ago
$time_90_minutes_ago

I am not sure how to handle midnight where if the time is 00:10:00
ninety minutes earlier is a day before.  Thanks.  Ron

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP-DB] Date Formatting Question

2005-12-14 Thread Bomgardner, Mark A
I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working.  

I am pulling the date out of MySQL with: 
$sDate = explode(-, $row_events['Sdate']);

And then attempting to insert each portion of the array into a drop down
menu with:
echo select name=Smonth;
echo option selected$sDate[1]/option;
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date(F,strtotime($sDate));  
Strftime(%B:,$sDate);
Date(F,$sDate);


I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.


Mark Bomgardner
Technology Specialist
KLETC

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



Re: [PHP-DB] Date Formatting Question

2005-12-14 Thread tg-php
You got the right idea, but you're making it more complicated than it needs to 
be.

your $sDate after using explode() is going to contain an array.  strtotime 
doesn't take an array, it takes a string.

$monthName = date(F, strtotime($row_events['Sdate']));
$monthNumber = date(m,  strtotime($row_events['Sdate']));
// or n if you want 1 instead of 01 for January

echo select name='sMonth'\n;
for ($i = 1; $i = 12; $i++) 

  // using date() below to get month name, day and year irrelevant
  $selectMonthText = date(F, mktime(0, 0, 0, $i, 1, 2000));

  if ($i == $monthNumber) 
$selected =  SELECTED;
   else 
$selected = ;
  
  echo option value='$i'$selected$selectMonthText/option\n;

echo /select\n;


-TG


= = = Original message = = =

I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working.  

I am pulling the date out of MySQL with: 
$sDate = explode(-, $row_events['Sdate']);

And then attempting to insert each portion of the array into a drop down
menu with:
echo select name=Smonth;
echo option selected$sDate[1]/option;
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date(F,strtotime($sDate));  
Strftime(%B:,$sDate);
Date(F,$sDate);


I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.


Mark Bomgardner
Technology Specialist
KLETC


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP-DB] DATE(r)

2005-09-09 Thread Ron Piggott
Question:

I am trying to for the first time create a table with a column that is
defined as datetime

I wanted to populate that column with the date(r) command.

date(r) on my web site gives this response:

Fri, 9 Sep 2005 13:32:19 -0400

How may I manipulate date(r) to give a format which is compatable to the
column type

-00-00 00:00:00
-MM-DD 24:59:59

Ron

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



RE: [PHP-DB] DATE(r)

2005-09-09 Thread Bastien Koert

use timestamp column type and populate it by

$date = strtottime(date(r));

then when you want to display it

$date = date('r',$row['datefieldname']);

Bastien



From: Ron Piggott [EMAIL PROTECTED]
Reply-To: Ron Piggott [EMAIL PROTECTED]
To: PHP DB php-db@lists.php.net
Subject: [PHP-DB] DATE(r)
Date: Fri, 9 Sep 2005 12:52:59 -0500

Question:

I am trying to for the first time create a table with a column that is
defined as datetime

I wanted to populate that column with the date(r) command.

date(r) on my web site gives this response:

Fri, 9 Sep 2005 13:32:19 -0400

How may I manipulate date(r) to give a format which is compatable to the
column type

-00-00 00:00:00
-MM-DD 24:59:59

Ron

--
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] DATE(r)

2005-09-09 Thread Jordan Miller

You need to use:
date('Y-m-d H:i:s');

It's in the comments at:
http://www.php.net/date

Jordan



On Sep 9, 2005, at 12:52 PM, Ron Piggott wrote:



Question:

I am trying to for the first time create a table with a column that is
defined as datetime

I wanted to populate that column with the date(r) command.

date(r) on my web site gives this response:

Fri, 9 Sep 2005 13:32:19 -0400

How may I manipulate date(r) to give a format which is compatable  
to the

column type

-00-00 00:00:00
-MM-DD 24:59:59

Ron

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



[PHP-DB] Date problem again ;-)

2005-03-22 Thread Chris Payne
Hi there everyone,

 

OK I'm using the following in my query to display entries in the LAST 3
days:

 

DATE_SUB(CURDATE(),INTERVAL 3 DAY) = ListingDate

 

But it doesn't seem to affect the results, the date format in my DB column
(ListingDate - datatype is Date) is 2000-00-00 as in year, month and date -
is THAT the problem?  That it needs to be an actual timestamp?  If that is
the case I'm not sure how to approach this because the data MUST be in the
above format as it comes from a central DB every night.  All I need to do is
display the current date plus also the previous x amount of days in between.

 

I'm using PHP 4 with MySQL 4.0.22 (Not the latest MySQL I know, sigh).

 

Chris



Re: [PHP-DB] Date problem again ;-)

2005-03-22 Thread Forest Liu
I suppose there is a  submit_time field in your DB table, so you could:
SELECT * FROM `tablename` WHERE `submit_time`=.lastdays(3)

lastdays() is a function you could create using mktime(),time(), and date()


On Tue, 22 Mar 2005 16:28:39 -0500, Chris Payne [EMAIL PROTECTED] wrote:
 Hi there everyone,
 
 OK I'm using the following in my query to display entries in the LAST 3
 days:
 
 DATE_SUB(CURDATE(),INTERVAL 3 DAY) = ListingDate
 
 But it doesn't seem to affect the results, the date format in my DB column
 (ListingDate - datatype is Date) is 2000-00-00 as in year, month and date -
 is THAT the problem?  That it needs to be an actual timestamp?  If that is
 the case I'm not sure how to approach this because the data MUST be in the
 above format as it comes from a central DB every night.  All I need to do is
 display the current date plus also the previous x amount of days in between.
 
 I'm using PHP 4 with MySQL 4.0.22 (Not the latest MySQL I know, sigh).
 
 
 Chris
 
 


-- 
   Sincerely,
 Forest Liu()

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



RE: [PHP-DB] date conversions

2004-12-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 December 2004 06:00, neil wrote:

 Hi
 
 I am needing to convert a d/m/y date such as 30/11/2004 into the
 format that mysql can use ie. 2004-11-20
 
 If I try the following:
 
 $testdate=30/11/2004;
 echo date(Y-m-d, strtotime($testdate));
 
 the result is - 2006-06-11

strtotime() is, unfortunately, a little American biased and only recognises
the mm/dd/ numeric format (using slashes).  So the above is returning
the equivalent of the 11th day of the 30th month of 2004!

You can use other PHP functions, as has been suggested, but you might also
investigate the mySQL date formatting functions, as I believe they work
perfectly well on input dates as well as output ones.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP-DB] date conversions

2004-12-15 Thread neil
Hi

I am needing to convert a d/m/y date such as 30/11/2004 into the format that
mysql can use ie. 2004-11-20

If I try the following:

$testdate=30/11/2004;
echo date(Y-m-d, strtotime($testdate));

the result is - 2006-06-11

I can't find any other function apart from strtotime to do this.

Any ideas?

Thanks
Neil

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



Re: [PHP-DB] date conversions

2004-12-15 Thread Jason Wong
On Thursday 16 December 2004 14:00, neil wrote:

 I am needing to convert a d/m/y date such as 30/11/2004 into the format
 that mysql can use ie. 2004-11-20

 If I try the following:

 $testdate=30/11/2004;
 echo date(Y-m-d, strtotime($testdate));

 the result is - 2006-06-11

 I can't find any other function apart from strtotime to do this.

Use the string functions to manipulate it into the required format, explode() 
is one approach. If you're desperate search the archives, hundreds of 
variations of code to do this have been posted in the past. But it might be 
quicker to write your own than to hit upon the appropriate keywords to search 
for.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
If practice makes perfect, and nobody's perfect, why practice?
*/

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



Re: [PHP-DB] date conversions

2004-12-15 Thread neil
Thank you for all your help.

Among all  the variations I found this to be the clearest:

list($d,$m,$y) = explode(/,$testdate);
$mysqldate = date(Y-m-d, mktime(0,0,0,$m,$d,$y));

But I also thought the use of split instead of explode so you could nominate
multiple delimiters was good.
eg.
list($d,$m,$y) = split('[/.-]', $testdate);

Another variation was to hardcode the date results instead of using the date
function which is very simple:
eg.
$mysqldate = $y.'-'.$m.'-'.$d;

Sorry for asking a question that is obviously asked often.

Interesting comment on 'normal'. I suspect that numerically more of the
world uses dmy than mdy. There is a lot more of the world outside the US
than in it.

Thanks again for all your help.

Neil


[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Yeah, this is my problem with relyinig on strtotime().  If you don't give
it a format that it knows, it's going to give you random results (well, not
random, but undesireable).  Seems like more of a crutch that leaves too
much chance of error for my taste.  I prefer to be a little more explicit:


 $testdate=30/11/2004;
 list($day,$month,$year) = explode(/,$testdate);
 echo date(Y-m-d, mktime(0,0,0,$month,$day,$year));

 Try that out.  mktime() produces a serial date/time just like strtotime()
but you have a little more control over what it's producing and subsequently
what gets piped into date().  This exact example is what I used once before
when arguing against using strtotime().  Most people are going to use a
'normal' format that strtotime() likes, but the format you're using
(european standard?) and just using the numbers is the one big instance that
strtotime() breaks.

 Hope this helps.  You should be able to get whatever date format you need
now.

 -TG

 *** new email address [EMAIL PROTECTED]
 *** old email address [EMAIL PROTECTED] YAY CHAPTER 11!  :(




 = = = Original message = = =

 Hi

 I am needing to convert a d/m/y date such as 30/11/2004 into the format
that
 mysql can use ie. 2004-11-20

 If I try the following:

 $testdate=30/11/2004;
 echo date(Y-m-d, strtotime($testdate));

 the result is - 2006-06-11

 I can't find any other function apart from strtotime to do this.

 Any ideas?

 Thanks
 Neil


 ___
 Sent by ePrompter, the premier email notification software.
 Free download at http://www.ePrompter.com.

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



[PHP-DB] Date Question

2004-10-27 Thread Bomgardner, Mark A
I am having trouble converting a date from mm/dd/ to -mm-dd on a
user form.  I know there was post about this, but I keep getting an
error message when I try to search the archives.

 

I have looked at the manual, but I am not finding what I am looking for.

 

Mark A. Bomgardner 
Technology Specialist 
KLETC 

 



RE: [PHP-DB] Date Question

2004-10-27 Thread Bastien Koert
How are you trying to convert the date?
bastien

From: Bomgardner, Mark A [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Date Question
Date: Wed, 27 Oct 2004 11:17:16 -0500
I am having trouble converting a date from mm/dd/ to -mm-dd on a
user form.  I know there was post about this, but I keep getting an
error message when I try to search the archives.

I have looked at the manual, but I am not finding what I am looking for.

Mark A. Bomgardner
Technology Specialist
KLETC

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


Re: [PHP-DB] Date Question

2004-10-27 Thread John Holmes
Bomgardner, Mark A wrote:
I am having trouble converting a date from mm/dd/ to -mm-dd on a
user form.  I know there was post about this, but I keep getting an
error message when I try to search the archives.
I have looked at the manual, but I am not finding what I am looking for.
echo date('Y-m-d',strtotime('09/24/2004'));
--
---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] Date Conversion

2004-08-18 Thread Ng Hwee Hwee
Hi all,

can someone kindly point me to a resource that converts all kinds of possible date 
inputs into MySQL format of -MM-DD?

example of formats to be converted includes:

d/m/yy
d/m/
d/mm/yy
d/mm/yyy
dd/mm/yy
dd/mm/yyy
d/mmm/yy
d/mmm/
dd/mmm/yy
dd/mmm/

yy   - 2 digit representation of year
   - ful numeric representation of year
m   - numeric representation of month, without leading zero
mm- numeric representation of month, with leading zero
mmm - short textual representation of month   
d   - day of month without leading zero
dd - day of month with leadin zero

thanx!

hwee

RE: [PHP-DB] Date problem: data is current as of yesterday

2004-07-03 Thread Ford, Mike [LSS]
-Original Message-
From: Karen Resplendo
To: [EMAIL PROTECTED]
Sent: 02/07/04 19:36
Subject: [PHP-DB] Date problem: data is current as of yesterday

The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little
snippet below returns yesterday's date, except that the first day of the
month returns 0 for the day. Now, I know why this is happening, but I
can't find out how to fix it (in VBA or SQL Server I would just say,
date()-1:
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo Data is current  as of  b$month $mday, $year/bbr;

--

The mktime() function is your friend for this kind of date arithmetic. For
example, this is one possible way to do what you want:

  $yesterday = mktime(12, 0, 0, $today['mon'], $today['mday']-1,
$today['year']);
  echo Data is current as of b.date(F j, Y, $yesterday);

(Note the use of time 12:00:00 to avoid daylight savings oddities!)

The examples on the date() and mktime() manual pages may suggest other
possibilities to you.

Cheers!

Mike
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

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



[PHP-DB] Date problem: data is current as of yesterday

2004-07-02 Thread Karen Resplendo
The database queries all the sources at night after everyone has gone home. That means 
the data was current as of yesterday. This little snippet below returns yesterday's 
date, except that the first day of the month returns 0 for the day. Now, I know why 
this is happening, but I can't find out how to fix it (in VBA or SQL Server I would 
just say, date()-1:
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo Data is current  as of  b$month $mday, $year/bbr;
 
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Re: [PHP-DB] Date problem: data is current as of yesterday

2004-07-02 Thread jeffrey_n_Dyke


accidentally replied only to karen.

 The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little snippet
below returns yesterday's date, except that the first day of the month
returns 0 for  the day. Now, I know why this is happening, but I can't
find out how to fix it (in VBA or SQL Server I would just  say,
date()-1:

 $today = getdate();
 $month = $today['month'] ;
 $mday = $today['mday'] -1;
 $year = $today['year'];
 echo Data is current  as of  b$month $mday, $year/bbr;

you can do the same thing with php.

I'd use a timestamp and subtract 86400 (24 hours of seconds)

$yesterday_at_this_time = date(Y-m-d H:i:s, time() - 86400);

hth
Jeff
-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

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



[PHP-DB] Date Select

2004-06-25 Thread Tom Chubb
How can I query a MySQL table to get the latest results from a date field?
Basically, I am inserting several records at a time at the end of each week.
I want to have a page that displays the results for the last week only.
The date format in the field is -MM-DD


Re: [PHP-DB] Date Select

2004-06-25 Thread jeffrey_n_Dyke



How can I query a MySQL table to get the latest results from a date field?
Basically, I am inserting several records at a time at the end of each
week.
I want to have a page that displays the results for the last week only.
The date format in the field is -MM-DD


if you want the latest row -
  select * from table order by max(date_column) limit 1;

if you want rows in a range of dates there are lots o ways, and instead of
showing one or two, I'd suggest taking a look at the manual on dates
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html, and seeing
what fits your needs best.  Seems like you may want to look at BETWEEN

And if you don't want to use those, you are always free to use
  select * from table where date_column  '-mm-dd' and date_column
 '-mm-dd' order by date_col desc

HTH
Jeff

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



RE: [PHP-DB] Date Select

2004-06-25 Thread Tom Chubb
Jeffrey,
Thanks for this,
I've just realised that it's always the same no of inserts, so perhaps I
should just order by date then my previous sort field and then limit the
result to 20?
(It's all 20 results that I need displayed)
Thanks,
Tom


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 25 June 2004 12:15
To: Tom Chubb
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date Select





How can I query a MySQL table to get the latest results from a date field?
Basically, I am inserting several records at a time at the end of each
week.
I want to have a page that displays the results for the last week only.
The date format in the field is -MM-DD


if you want the latest row -
  select * from table order by max(date_column) limit 1;

if you want rows in a range of dates there are lots o ways, and instead of
showing one or two, I'd suggest taking a look at the manual on dates
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html, and seeing
what fits your needs best.  Seems like you may want to look at BETWEEN

And if you don't want to use those, you are always free to use
  select * from table where date_column  '-mm-dd' and date_column
 '-mm-dd' order by date_col desc

HTH
Jeff

--
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] Date help needed

2004-06-25 Thread Neil Smith [MVP, Digital media]
No, it's actually very easy to do the autocomplete once you get the hang of 
it. Actually the way I've done it is to populate a multi-select box but you 
could also use a DIV and write out the values

Dump the email addresses as an XML file (generate this dynamically) then 
use XSLT to read out matching rows on each keyup ... basically you filter 
the XML file each time till you get down to one value

Yes, it's javascript but it works really well as long as you have some 
control over your client browser (in the case of your boss, probably IE but 
it can be made to work in mozilla / firefox too)

Mail me offlist if you want a working example.
Cheers - Neil
At 11:07 25/06/2004 +, you wrote:
Message-Id: [EMAIL PROTECTED]
From: Chris Payne [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Thu, 24 Jun 2004 22:53:13 -0400
MIME-Version: 1.0
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: RE: [PHP-DB] Date help needed
One thing he wanted which I didn't know how to do (Javascript I guess which
I don't know much about) was to preload a database of email address, and as
he started to type an email address it would do a sort of auto-complete, but
have no clue how to go about that so just told him not viable ATM.


CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.
VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Date help needed

2004-06-24 Thread Chris Payne
Hi there everyone,

 

I have a problem, I currently have some code which populates a dropdown box
- this code gives me every day for the next x amount of days (EG: a years
worth of days), however what I really need to be able to do, is to find a
way to display this data in the dropdown box but ONLY show 3 days a week,
IE: Mondays, Fridays and Sundays, so it would show the dates for each
Monday, Friday and Sunday for X amount of days (IE: 365 days in the
dropdown).

 

Does anyone have any idea how to do this?  I would really appreciate any
help, I'd send my sample code only I'm not at my home/work computer ATM.

 

Chris



Re: [PHP-DB] Date help needed

2004-06-24 Thread Justin Patrin
You could loop through the weeks and put those 3 specifically in:
$days = array();
for($i = 0; $i  365; $i +=7) {
  $days[] = strtotime('next Monday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Friday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Sunday', strtotime('+ '.$i.' days'));
}

sort($days);

foreach($days as $day) {
  echo date('Y-m-d', $day).'br/';
}

(This is not tested, but it *should* work,)

On Thu, 24 Jun 2004 17:07:12 -0400, Chris Payne
[EMAIL PROTECTED] wrote:
 
 Hi there everyone,
 
 I have a problem, I currently have some code which populates a dropdown box
 - this code gives me every day for the next x amount of days (EG: a years
 worth of days), however what I really need to be able to do, is to find a
 way to display this data in the dropdown box but ONLY show 3 days a week,
 IE: Mondays, Fridays and Sundays, so it would show the dates for each
 Monday, Friday and Sunday for X amount of days (IE: 365 days in the
 dropdown).
 
 Does anyone have any idea how to do this?  I would really appreciate any
 help, I'd send my sample code only I'm not at my home/work computer ATM.
 
 Chris
 
 !DSPAM:40db40cb34094233914063!
 


-- 
paperCrane --Justin Patrin--

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



RE: [PHP-DB] Date help needed

2004-06-24 Thread Chris Payne
Hi there,

Just got back and tried it and it works perfectly, thank you so much for
your help, you've got me out of a bind here ;-)

Chris

You could loop through the weeks and put those 3 specifically in:
$days = array();
for($i = 0; $i  365; $i +=7) {
  $days[] = strtotime('next Monday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Friday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Sunday', strtotime('+ '.$i.' days'));
}

sort($days);

foreach($days as $day) {
  echo date('Y-m-d', $day).'br/';
}

(This is not tested, but it *should* work,)

On Thu, 24 Jun 2004 17:07:12 -0400, Chris Payne
[EMAIL PROTECTED] wrote:
 
 Hi there everyone,
 
 I have a problem, I currently have some code which populates a dropdown
box
 - this code gives me every day for the next x amount of days (EG: a years
 worth of days), however what I really need to be able to do, is to find a
 way to display this data in the dropdown box but ONLY show 3 days a week,
 IE: Mondays, Fridays and Sundays, so it would show the dates for each
 Monday, Friday and Sunday for X amount of days (IE: 365 days in the
 dropdown).
 
 Does anyone have any idea how to do this?  I would really appreciate any
 help, I'd send my sample code only I'm not at my home/work computer ATM.
 
 Chris
 
 !DSPAM:40db40cb34094233914063!
 


-- 
paperCrane --Justin Patrin--

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



Re: [PHP-DB] Date help needed

2004-06-24 Thread Daniel Clark
A drop down with 365 days !?!?   Isn't that a little big?

 I have a problem, I currently have some code which populates a dropdown
 box
 - this code gives me every day for the next x amount of days (EG: a years
 worth of days), however what I really need to be able to do, is to find a
 way to display this data in the dropdown box but ONLY show 3 days a week,
 IE: Mondays, Fridays and Sundays, so it would show the dates for each
 Monday, Friday and Sunday for X amount of days (IE: 365 days in the
 dropdown).



 Does anyone have any idea how to do this?  I would really appreciate any
 help, I'd send my sample code only I'm not at my home/work computer ATM.

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



RE: [PHP-DB] Date help needed

2004-06-24 Thread Chris Payne
Hi there,

A drop down with 365 days !?!?   Isn't that a little big?

Actually it's Fridays, Sundays and Tuesdays for 2 years (365 was an example)
it's for an Admin for a client, and he asked that it be in a dropdown box
and he's the boss, so he gets what he wants :-)

One thing he wanted which I didn't know how to do (Javascript I guess which
I don't know much about) was to preload a database of email address, and as
he started to type an email address it would do a sort of auto-complete, but
have no clue how to go about that so just told him not viable ATM.

Chris

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



[PHP-DB] date and time problem

2004-05-14 Thread Kim Jacobs - MWEB

 Hi guys
 
 I have a script which pulls a date(date default NULL) and a time (time default NULL) 
 from a MySQL database, now I would like to display that date and time in a 'pretty' 
 format.
 
 I've been able to show the date nicely with the help of this:
 
   $ntime=strtotime($row['date'] $row['time']);
   $ndate=date('D d F Y H:i',$ntime);
 
 This shows the date in a 'nice' format (2004-05-10 20:40:00 is shown as Mon 10 May 
 2004 00:00), however, it shows the time as 00:00 for all of the games no matter what 
 the time is. How do I get it to show the date as 20:40 or 20h40 or 8:40 PM?
 
 If I change the lines to this:
   $ntime=strtotime($row[date] $row[time] GMT);
   $ndate=date('D d F Y H:i',$ntime);
 the only difference is that it now shows Mon 10 May 2004 02:00 (probably because we 
 are 2 hours ahead of GMT)
 
 Any ideas please?
 
 Thanks
 K
 
MWEB: S.A.'s most trusted and reliable Internet Service Provider. Just Like That. 

To join, go to: http://join.mweb.co.za or call 0860032000.

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



[PHP-DB] Date SELECT with IF

2004-04-15 Thread Shaun
Hi,

Is it possible to have a clause in a mysql SELECT statement? I would the
query to display the date except where it equals the default 000-00-00 to
display n/a or something similar.

For example SELECT DATE_FORMAT(B.Booking_End_Date, \%Y-%m-%d\) AS 'Booking
End Date' FROM Bookings (IF Booking_End_Date = '-00-00' DISPLAY 'n/a');

I hope this illustrates what I am trying to achieve!

Thanks for your help

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



Re: [PHP-DB] Date SELECT with IF

2004-04-15 Thread Ignatius Reilly
SELECT
IF( B.Booking_End_Date != -00-00,
DATE_FORMAT( B.Booking_End_Date, %Y-%m-%d ),
N/A
) AS Booking_End_Date
FROM Bookings AS B, etc.

HTH
Ignatius
_
- Original Message -
From: Shaun [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 7:44 PM
Subject: [PHP-DB] Date SELECT with IF


 Hi,

 Is it possible to have a clause in a mysql SELECT statement? I would the
 query to display the date except where it equals the default 000-00-00 to
 display n/a or something similar.

 For example SELECT DATE_FORMAT(B.Booking_End_Date, \%Y-%m-%d\) AS
'Booking
 End Date' FROM Bookings (IF Booking_End_Date = '-00-00' DISPLAY
'n/a');

 I hope this illustrates what I am trying to achieve!

 Thanks for your help

 --
 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] Date SELECT with IF

2004-04-15 Thread Marcjon Louwersheimer
try the WHERE clause.
SELECT name, address, phone, date FROM usertable WHERE date =
'-00-00'
And please, look at the mysql documentation, or at least the tutorial.
-- 
  Marcjon

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



[PHP-DB] Date Manipulation

2004-03-21 Thread Shannon Doyle
Hi People,

Need some assistance in the following scenario:-

Inserting a date into the database that is entered into a form by the site
visitor. - This is easy enough.

However I now need to use the same date that has been entered by the site
visitor add 35 days and then insert into another table.

My question, how do I get the date entered into the form add 35days to it
and then include that into the same sql query as the first one. Or do I have
to use a second sql query? If the second query how would I get the date and
add 35days??


Cheers,

Shannon

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



Re: [PHP-DB] Date Manipulation

2004-03-21 Thread John W. Holmes
Shannon Doyle wrote:

My question, how do I get the date entered into the form add 35days to it
and then include that into the same sql query as the first one. Or do I have
to use a second sql query? If the second query how would I get the date and
add 35days??
INSERT INTO table (date1, date2) VALUES (20040321, 20040321 + INTERVAL 
35 DAY)

--
---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] date problem in MySQL DB

2004-01-13 Thread Angelo Zanetti
Hi guys

This might be slightly off topic but hopefully someone can help.
I have a field that is a varchar and I stored dates in it. But now I want to
change the type of the column to date, but I have a problem that the formats
differ:

my format: mm/dd/
mySQL format: -mm-dd

So can I either:
a. change the format of the date format

or

b. do i have to write a function that changes my format to the mySQL before
changing the column type??

TIA

Angelo Zanetti


Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread CPT John W. Holmes
From: Angelo Zanetti [EMAIL PROTECTED]

 This might be slightly off topic but hopefully someone can help.
 I have a field that is a varchar and I stored dates in it. But now I want
to
 change the type of the column to date, but I have a problem that the
formats
 differ:

 my format: mm/dd/
 mySQL format: -mm-dd

 So can I either:
 a. change the format of the date format

 or

 b. do i have to write a function that changes my format to the mySQL
before
 changing the column type??

You need to do option (b). Since this is a PHP list, I'd recommend
strtotime() and date() to do the formatting.

---John Holmes...

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



RE: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread brett king


Hi Angelo

Yes you will have to reformat and he is something that may help you.
Hope it does

function dateCheckMysql ($date) {

list($dateDay, $dateMonth, $dateYear) = explode(/, $date);
if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {

if (!checkdate($dateMonth, $dateDay, $dateYear)) {
return false;
} else {

return($dateYear./.$dateMonth./.$dateDay);
}
} else {

return false;
}
}

function dateCheckForm($date) {

list($dateYear, $dateMonth, $dateDay) = explode(-, $date);

if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {

return($dateDay./.$dateMonth./.$dateYear);
} else {
return false;
}
}

Many Thanks
Brett

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



Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread Justin Patrin
Brett King wrote:

Hi Angelo

Yes you will have to reformat and he is something that may help you.
Hope it does
	function dateCheckMysql ($date) {

list($dateDay, $dateMonth, $dateYear) = explode(/, $date);
if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {
if (!checkdate($dateMonth, $dateDay, $dateYear)) {
return false;
} else {
return($dateYear./.$dateMonth./.$dateDay);
}
} else {
return false;
}
}
	function dateCheckForm($date) {

		list($dateYear, $dateMonth, $dateDay) = explode(-, $date);

if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {
return($dateDay./.$dateMonth./.$dateYear);
} else {
return false;
}
}
Many Thanks
Brett
Wow, that's lots of code. I'd recommend something simpler. Like:

$mysqlDate = date('Y-m-d', strtotime($myDate));

$myDate = date('m/d/Y', strtotime($mysqlDate));

No checking involved, just one line of code.

--
paperCrane Justin Patrin
--
Question Everything, Reject Nothing
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] date function

2003-11-02 Thread OpenSource
Hi guys,

This might not be the best place for this but here goes.

I want to create a dropdown list with a date range of
--
SELECT name=bdate
 OPTION value=11/02/2003 SELECTEDToday
 OPTION value=11/01/2003Yesterday
 OPTION value=10/31/2003Fri 10/31
 OPTION value=10/30/2003Thu 10/30
 OPTION value=10/29/2003Wed 10/29
 OPTION value=10/28/2003Tue 10/28
 OPTION value=10/27/2003Mon 10/27
 OPTION value=10/26/2003Sun 10/26
 OPTION value=10/25/2003Sat 10/25
 OPTION value=10/24/2003Fri 10/24
 OPTION value=10/23/2003Thu 10/23
 OPTION value=10/22/2003Wed 10/22
 OPTION value=10/21/2003Tue 10/21
 OPTION value=10/20/2003Mon 10/20
 OPTION value=10/19/2003Sun 10/19
 OPTION value=10/12/2003Sun 10/12
 OPTION value=10/05/2003Sun 10/5
 OPTION value=09/28/2003Sun 9/28
 OPTION value=09/21/2003Sun 9/21
 OPTION value=09/14/2003Sun 9/14
 OPTION value=08/31/2003Sun 8/31
 OPTION value=08/01/2003Fri 8/1
 OPTION value=07/02/2003Wed 7/2
 OPTION value=06/02/2003Mon 6/2
 OPTION value=05/03/2003Sat 5/3
 OPTION value=04/03/2003Thu 4/3
 OPTION value=03/04/2003Tue 3/4
 OPTION value=02/02/2003Sun 2/2
 OPTION value=01/03/2003Fri 1/3
 OPTION value=12/04/2002Wed 12/4
/SELECT
--
I would like to know i can go about doing that. some examples, or if anyone has a 
function already the i could use.


Thanks in advance,



Re: [PHP-DB] date function

2003-11-02 Thread Larry E . Ullman
This might not be the best place for this but here goes.
You are correct. At the very least, you should probably be using the 
general PHP list, not the database one.

I want to create a dropdown list with a date range of
Not to be obstinate, but it looks like you already have. But, assuming 
that you mean that you want to create this dynamically in PHP starting 
with today's date, then you need to establish some guidelines or rules 
for what dates make up the list. I can't really see a pattern in your 
list (every day for two weeks, then every week for five weeks, then two 
weeks once, then monthly going back a year) so I can't offer specifics. 
The answer will probably be found using a for loop and the date 
function.

Larry

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


Re: [PHP-DB] date function

2003-11-02 Thread Ignatius Reilly
have a look at the PEAR date package.
http://pear.php.net/package/Date

_
- Original Message -
From: OpenSource [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, November 02, 2003 11:13 PM
Subject: [PHP-DB] date function


Hi guys,

This might not be the best place for this but here goes.

I want to create a dropdown list with a date range of
--
SELECT name=bdate
 OPTION value=11/02/2003 SELECTEDToday
 OPTION value=11/01/2003Yesterday
 OPTION value=10/31/2003Fri 10/31
 OPTION value=10/30/2003Thu 10/30
 OPTION value=10/29/2003Wed 10/29
 OPTION value=10/28/2003Tue 10/28
 OPTION value=10/27/2003Mon 10/27
 OPTION value=10/26/2003Sun 10/26
 OPTION value=10/25/2003Sat 10/25
 OPTION value=10/24/2003Fri 10/24
 OPTION value=10/23/2003Thu 10/23
 OPTION value=10/22/2003Wed 10/22
 OPTION value=10/21/2003Tue 10/21
 OPTION value=10/20/2003Mon 10/20
 OPTION value=10/19/2003Sun 10/19
 OPTION value=10/12/2003Sun 10/12
 OPTION value=10/05/2003Sun 10/5
 OPTION value=09/28/2003Sun 9/28
 OPTION value=09/21/2003Sun 9/21
 OPTION value=09/14/2003Sun 9/14
 OPTION value=08/31/2003Sun 8/31
 OPTION value=08/01/2003Fri 8/1
 OPTION value=07/02/2003Wed 7/2
 OPTION value=06/02/2003Mon 6/2
 OPTION value=05/03/2003Sat 5/3
 OPTION value=04/03/2003Thu 4/3
 OPTION value=03/04/2003Tue 3/4
 OPTION value=02/02/2003Sun 2/2
 OPTION value=01/03/2003Fri 1/3
 OPTION value=12/04/2002Wed 12/4
/SELECT
--
I would like to know i can go about doing that. some examples, or if anyone
has a function already the i could use.


Thanks in advance,

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



Re: [PHP-DB] date function

2003-11-02 Thread Martin Marques
1) Why do you send this to a DB list?
2) Try seeing the Date class of PEAR (PEAR::Date).

El Dom 02 Nov 2003 19:13, OpenSource escribió:
 Hi guys,
 
 This might not be the best place for this but here goes.
 
 I want to create a dropdown list with a date range of
 --
 SELECT name=bdate
  OPTION value=11/02/2003 SELECTEDToday
  OPTION value=11/01/2003Yesterday
  OPTION value=10/31/2003Fri 10/31
  OPTION value=10/30/2003Thu 10/30
  OPTION value=10/29/2003Wed 10/29
  OPTION value=10/28/2003Tue 10/28
  OPTION value=10/27/2003Mon 10/27
  OPTION value=10/26/2003Sun 10/26
  OPTION value=10/25/2003Sat 10/25
  OPTION value=10/24/2003Fri 10/24
  OPTION value=10/23/2003Thu 10/23
  OPTION value=10/22/2003Wed 10/22
  OPTION value=10/21/2003Tue 10/21
  OPTION value=10/20/2003Mon 10/20
  OPTION value=10/19/2003Sun 10/19
  OPTION value=10/12/2003Sun 10/12
  OPTION value=10/05/2003Sun 10/5
  OPTION value=09/28/2003Sun 9/28
  OPTION value=09/21/2003Sun 9/21
  OPTION value=09/14/2003Sun 9/14
  OPTION value=08/31/2003Sun 8/31
  OPTION value=08/01/2003Fri 8/1
  OPTION value=07/02/2003Wed 7/2
  OPTION value=06/02/2003Mon 6/2
  OPTION value=05/03/2003Sat 5/3
  OPTION value=04/03/2003Thu 4/3
  OPTION value=03/04/2003Tue 3/4
  OPTION value=02/02/2003Sun 2/2
  OPTION value=01/03/2003Fri 1/3
  OPTION value=12/04/2002Wed 12/4
 /SELECT
 --
 I would like to know i can go about doing that. some examples, or if anyone 
has a function already the i could use.
 
 
 Thanks in advance,
 
 

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telemática
   Universidad Nacional
del Litoral
-

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



[PHP-DB] Date Pulldown

2003-11-02 Thread Peter Westergaard
Sorry for what is probably going to be a late reply.  I'm waiting to pick 
someone up at the airport, and the plane was delayed, so I wanted to try my 
hand at answering your question.

First I had to figure out what method you used to pick those dates in the 
first place.  It seems to be...

Today, Yesterday, then 1 day back for a total of 14 days (2 weeks)
Then going 1 week back for a total of 8 weeks (56 days)
Then I'm stumped how you came up with the jump from 9/14 to 8/31 to 
8/1 unless the rule is go back 2 weeks then go back 30 days...
Is there a reason the next rule can't be: go 1 month back for a total of 11 
months?

Here's a little piece of PHP code which will do just about exactly what 
you're looking for, with the rule modification I suggested.  Perhaps it 
will do the trick?  (And, since I'm no guru myself, I welcome comments on 
my suggestion).  It basically works around mktime and date.  Both are 
very good functions to accomplish what you're trying to accomplish.  Read 
up on those and you should be able to handle it.

form name=foo
select name=bdate
?php
	output_date_option ( mktime(0,0,0, date(m), date(d), date(Y)) , 
Today , SELECTED );
	output_date_option ( mktime(0,0,0, date(m), date(d)-1, date(Y)) , 
Yesterday );
	for ($days = 2; $days = 14; $days++) {
	output_date_option ( mktime(0,0,0, date(m), date(d)-$days, 
date(Y)) );
	}
	for ($weeks = 3; $weeks = 7; $weeks++) {
	output_date_option ( mktime(0,0,0, date(m), date(d)-($weeks*7), 
date(Y)) );
	}
	for ($months = 2; $months = 11; $months++) {
	output_date_option ( mktime(0,0,0, date(m)-$months, date(d), 
date(Y))  );
	}

function output_date_option($current_date, $date_string = , $xparams = ) {
	if (!isset($date_string) or $date_string == ) {
		$date_string = date ( D m/d , $current_date );
	}
	echo ( 'OPTION VALUE='.date ( m/d/Y , $current_date ).' 
'.$xparams.''.$date_string );
}
?
/select
/form

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


[PHP-DB] date function

2003-09-05 Thread Darryl
Greetings,
I have some php code that pulls from the mysql database.  Here it is:

?php
 mysql_connect(wildcat.osborneindustries.com, webuser,
webpass);
   $mymonth = date('n');
   $cyear = date('Y');
 $query = SELECT name,hdate FROM emp2 where month(hdate)=$mymonth
order by hdate;
 $result = mysql_db_query(iweb, $query);

 if ($result) {
   echo table align=center  border=0  cellspacing=5 ;
   while ($r = mysql_fetch_array($result)) {
  $name = $r[name];
 $hyear = date('Y',$r[hdate]);
 $timein = $cyear - $hyear;
 if ($timein  0) {
echo
trtd$name/ttd$timein/tdtd$cyear/tdtd$hyear/td/tr;}
   }
   echo /table;
 } else {
echo No data.;
}
mysql_free_result($result); ?

I'm trying to figure out years of employment based on hiredate.  Its not
working as expected.  $timein is always
1969.  Date in the database is -MM-DD.  What have I screwed up ?

thanks,
Darryl

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



Re: [PHP-DB] date function

2003-09-05 Thread Jason Wong
On Saturday 06 September 2003 06:01, Darryl wrote:

 I have some php code that pulls from the mysql database.  Here it is:

 ?php
  mysql_connect(wildcat.osborneindustries.com, webuser,
 webpass);
$mymonth = date('n');
$cyear = date('Y');
  $query = SELECT name,hdate FROM emp2 where month(hdate)=$mymonth
 order by hdate;
  $result = mysql_db_query(iweb, $query);

  if ($result) {
echo table align=center  border=0  cellspacing=5 ;
while ($r = mysql_fetch_array($result)) {
   $name = $r[name];
  $hyear = date('Y',$r[hdate]);
  $timein = $cyear - $hyear;
  if ($timein  0) {
 echo
 trtd$name/ttd$timein/tdtd$cyear/tdtd$hyear/td/tr;}
}
echo /table;
  } else {
 echo No data.;
 }
 mysql_free_result($result); ?

 I'm trying to figure out years of employment based on hiredate.  Its not
 working as expected.  $timein is always
 1969.  Date in the database is -MM-DD.  What have I screwed up ?

date() in php expects a unix timestamp. Dates in MySQL are NOT stored in unix 
timestamp format.

You can perform the calculations directly in MySQL

mysql manual  Tutorial Introduction  Date Calculations


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
People with narrow minds usually have broad tongues.
*/

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



[PHP-DB] Date format problem

2003-08-14 Thread Dani Matielo
Hello,

I have a field in my mysql db wich is a timestamp with the format

mmddhhmmss

and I would like to display it like:

dd/mm/

how do I do that?

Thank you in advance,

Dani


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 18/7/2003



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



RE: [PHP-DB] Date format problem

2003-08-14 Thread Jennifer Goodie
 
 I have a field in my mysql db wich is a timestamp with the format
 
 mmddhhmmss
 
 and I would like to display it like:
 
 dd/mm/
 
http://www.mysql.com/doc/en/Date_and_time_functions.html#IDX1333

SELECT DATE_FORMAT(timestamp_col_name, '%d/%m/%Y') FROM table_name

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



[PHP-DB] Date problem

2003-07-14 Thread Chris Payne
Hi there everyone,

I use the below code to grab the current date, convert it to a unix timestamp to do 
some bits then it's supposed to change the date back with the new values (IE: current 
date - x amount of seconds) but it's not doing it correctly, it's probably DEAD 
obvious to everyone as my brain has probably fried :-)  But here's the code, when I 
convert it back to d,m,Y it says it's 2004 which it shouldn't.

Thanks

Chris

---

$secsinweek = 604800;

$numweeks = $secsinweek * 7;

$curdate = date(d-m-Y);

// Split the strings into day, month, year
list($cd, $cm, $cy) = split(-, $curdate);

// Create unix time stamps for the start and end date
 $now = mktime(0,0,0,$cd,$cm,$cy);

// Do some number crunching here //

$newnow = $now-$numweeks;

echo $now;

$converted_date = date(d-m-y,$now);

echo br$converted_date;

RE: [PHP-DB] Date problem

2003-07-14 Thread Gary . Every
snip
 // Do some number crunching here //
 
 $newnow = $now-$numweeks;
 
 echo $now;
 
 $converted_date = date(d-m-y,$now);
 
 echo br$converted_date;

/snip

You should be running your $convewrted_date on $newnow, not $now




Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


 -Original Message-
 From: Chris Payne [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 14, 2003 3:45 AM
 To: php
 Subject: [PHP-DB] Date problem
 
 
 Hi there everyone,
 
 I use the below code to grab the current date, convert it to 
 a unix timestamp to do some bits then it's supposed to change 
 the date back with the new values (IE: current date - x 
 amount of seconds) but it's not doing it correctly, it's 
 probably DEAD obvious to everyone as my brain has probably 
 fried :-)  But here's the code, when I convert it back to 
 d,m,Y it says it's 2004 which it shouldn't.
 
 Thanks
 
 Chris
 
 ---
 
 $secsinweek = 604800;
 
 $numweeks = $secsinweek * 7;
 
 $curdate = date(d-m-Y);
 
 // Split the strings into day, month, year
 list($cd, $cm, $cy) = split(-, $curdate);
 
 // Create unix time stamps for the start and end date
  $now = mktime(0,0,0,$cd,$cm,$cy);
 
 // Do some number crunching here //
 
 $newnow = $now-$numweeks;
 
 echo $now;
 
 $converted_date = date(d-m-y,$now);
 
 echo br$converted_date;
 


[PHP-DB] date, and time?

2003-07-10 Thread Tristan . Pretty
Cheers for the help on my last auto inc prob..
I checked out phpmyadmin, and I'm loving it...! cheers all

Anyway,
I want to know how to store a date like this in a MySQL database:

date(F j, Y, g:i a);

Resulting in:

July 10, 2003, 3:39 am

But what do I need to set my database table to, to capture the full data.
I can use text, but then I can't sort by date later on

Ideas?

Cheers list...

*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***



Re: [PHP-DB] date, and time?

2003-07-10 Thread jeffrey_n_Dyke

you could change mysql to a few different date formats, but i don't _think_
that is one of them.

Why not just take care of a format change on the way out with DATE_FORMAT.
Also, if you store the date as one of the defualt date[time] values then
you have tons of functions that you can run against your data...

http://www.mysql.com/doc/en/Date_and_time_types.html
http://www.mysql.com/doc/en/Date_and_time_functions.html

hth
jeff


   

  [EMAIL PROTECTED]
 
  sungard.com To:   [EMAIL PROTECTED]  
 
  cc:  

  07/10/2003 11:02 AM Subject:  [PHP-DB] date, and time?   

   

   





Cheers for the help on my last auto inc prob..
I checked out phpmyadmin, and I'm loving it...! cheers all

Anyway,
I want to know how to store a date like this in a MySQL database:

date(F j, Y, g:i a);

Resulting in:

July 10, 2003, 3:39 am

But what do I need to set my database table to, to capture the full data.
I can use text, but then I can't sort by date later on

Ideas?

Cheers list...

*
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
***







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



[PHP-DB] Date Formatting in PHP

2003-06-10 Thread David Shugarts
 


I have a simple need to reformat a variable coming in as $DatePick, brought
forward from a MySQL select in the format:

2003-11-18

I need to convert it to the format

November 18, 2003

I am trying to avoid having to mess with the MySQL select statement, as the
output is being passed through several documents. So I need to do it within
PHP.

I tried making a conversion like

$DayReport = date (F d, Y, $DatePick);

But the value of $DayReport is neither correct nor does it change when
$DatePick changes. For instance, in this example, the $DatePick value of
2003-11-18 gets converted to December 31, 1969.

TIA

Dave Shugarts



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



Re: [PHP-DB] Date Formatting in PHP

2003-06-10 Thread Frank Keessen
Hi David,

Try this one:

?
function formatDate($val)
{
 setlocale (LC_ALL, '');
 $arr = explode(-, $val);
 return strftime (%A %e %B %Y, mktime (0, 0, 0, $arr[1], $arr[2],
$arr[0]));
}

echo formatDate($DatePick);
?

Regards,

Frank
- Original Message - 
From: David Shugarts [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, June 10, 2003 11:23 PM
Subject: [PHP-DB] Date Formatting in PHP





 I have a simple need to reformat a variable coming in as $DatePick,
brought
 forward from a MySQL select in the format:

 2003-11-18

 I need to convert it to the format

 November 18, 2003

 I am trying to avoid having to mess with the MySQL select statement, as
the
 output is being passed through several documents. So I need to do it
within
 PHP.

 I tried making a conversion like

 $DayReport = date (F d, Y, $DatePick);

 But the value of $DayReport is neither correct nor does it change when
 $DatePick changes. For instance, in this example, the $DatePick value of
 2003-11-18 gets converted to December 31, 1969.

 TIA

 Dave Shugarts



 -- 
 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] Date Formatting in PHP

2003-06-10 Thread John R Wunderly
At 05:23 PM 6/10/2003 -0400, David Shugarts wrote:


I have a simple need to reformat a variable coming in as $DatePick, brought
forward from a MySQL select in the format:
2003-11-18

I need to convert it to the format

November 18, 2003
try the dice-n-slice method.  use substr and concatenation to build 
$DayReport from the current value of $DatePick.

I am trying to avoid having to mess with the MySQL select statement, as the
output is being passed through several documents. So I need to do it within
PHP.
I tried making a conversion like

$DayReport = date (F d, Y, $DatePick);

But the value of $DayReport is neither correct nor does it change when
$DatePick changes. For instance, in this example, the $DatePick value of
2003-11-18 gets converted to December 31, 1969.
TIA

Dave Shugarts



--
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] Date Formatting in PHP

2003-06-10 Thread CPT John W. Holmes
 I have a simple need to reformat a variable coming in as $DatePick,
brought
 forward from a MySQL select in the format:

 2003-11-18

 I need to convert it to the format

 November 18, 2003

$f_date = date('F d, Y',strtotime($db_date));

---John Holmes...


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



Re: [PHP-DB] Date Formatting in PHP

2003-06-10 Thread David Shugarts


This worked perfectly, is very simple for me to use, and I would never have
come upon it in 10,000 years of trying. Thanks!

Thanks also to everyone who offered ideas.

 $f_date = date('F d, Y',strtotime($db_date));


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



[PHP-DB] date to Y-M-D

2003-03-25 Thread David Rice
a function to convert any date to ymd...

function datetoymd($date){
$dateymd = date('Y-m-d',$date);
return $dateymd;
}
this function when output gives me the date 1970-01-01 (date of the unix 
timestamp start) so, ehm, why!?

cheers,
dave




_
Stay in touch with absent friends - get MSN Messenger 
http://messenger.msn.co.uk

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


Re: [PHP-DB] date to Y-M-D

2003-03-25 Thread CPT John W. Holmes
 function datetoymd($date){
 $dateymd = date('Y-m-d',$date);

 return $dateymd;
 }

 this function when output gives me the date 1970-01-01 (date of the unix
 timestamp start) so, ehm, why!?

Because you're not passing a valid Unix timestamp or whatever your passing
is empty.

---John Holmes...


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



RE: [PHP-DB] date to Y-M-D

2003-03-25 Thread Snijders, Mark
ehmmm what kind of dates do you use, maybe dates of birth?

when using date of unix timestamp you can't have dates befor 1970  so if
those timestamps represents an older date you can't use timestamps!

-mark-


-Oorspronkelijk bericht-
Van: David Rice [mailto:[EMAIL PROTECTED]
Verzonden: Tuesday, March 25, 2003 3:42 PM
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP-DB] date to Y-M-D


a function to convert any date to ymd...


function datetoymd($date){
$dateymd = date('Y-m-d',$date);

return $dateymd;
}

this function when output gives me the date 1970-01-01 (date of the unix 
timestamp start) so, ehm, why!?

cheers,
dave





_
Stay in touch with absent friends - get MSN Messenger 
http://messenger.msn.co.uk


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



[PHP-DB] Date in a dropbox box

2003-03-10 Thread Chris Payne
Hi there everyone,

I have a form which displays 3 dropdowns, day, month and year, I have it displaying 
the default of the dropdown for month no problem, but how can I get it to select the 
current date (day) in the dropdown, but show 31 days nomatter how many days are in the 
month?  This is important even though it sounds odd :-)

so if it was the 5th of a month, it would show 5 as a default value, but allow you to 
select 1-4 before that and 6-31 after it.

Thanks everyone

Chris

RE: [PHP-DB] Date in a dropbox box

2003-03-10 Thread John W. Holmes
 I have a form which displays 3 dropdowns, day, month and year, I have
it
 displaying the default of the dropdown for month no problem, but how
can I
 get it to select the current date (day) in the dropdown, but show 31
days
 nomatter how many days are in the month?  This is important even
though it
 sounds odd :-)
 
 so if it was the 5th of a month, it would show 5 as a default value,
but
 allow you to select 1-4 before that and 6-31 after it.

Lots of ways you can do it.

$today = date('d');
for($x=1;$x=31;$x++)
{
echo 'option value=$x' . (($x==$today)?' selected':'') .
'$x/option';
}

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



Re: [PHP-DB] Date in a dropbox box

2003-03-10 Thread Chris Payne
Hi there,

Thank you John, you are a lifesaver :-)

Chris

  I have a form which displays 3 dropdowns, day, month and year, I have
 it
  displaying the default of the dropdown for month no problem, but how
 can I
  get it to select the current date (day) in the dropdown, but show 31
 days
  nomatter how many days are in the month?  This is important even
 though it
  sounds odd :-)
  
  so if it was the 5th of a month, it would show 5 as a default value,
 but
  allow you to select 1-4 before that and 6-31 after it.
 
 Lots of ways you can do it.
 
 $today = date('d');
 for($x=1;$x=31;$x++)
 {
 echo 'option value=$x' . (($x==$today)?' selected':'') .
 '$x/option';
 }
 
 ---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

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



Re: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread David Rice
Sorry, I forgot to add the part at the bottom where I am calling the 
function

=

?
function tips($weekstart){
	$start = date('Ymd',strtotime($weekstart));

 	$query = SELECT * FROM Rota WHERE date = $start and date = ($start + 
INTERVAL 6 DAY) ORDER BY staffid;
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result)){

		if ( isset ( $tips ) ){

			if (isset ( $tips[$row[staffid]] ) ){

$hours = $row[finish] - $row[start];
$tips[$row[staffid]] = $tips[$row[staffid]] + $hours;
			}

			else{

$tips[$row[staffid]] = $row[finish] - $row[start];

}
}
		else{

			$tips = array('$row[staffid]' =( $row[finish] - $row[start] ) );

		}

	}

	return $tips;

}

function dbconnect(){
mysql_connect(localhost, filterseveuk, godisadj);
mysql_select_db(filterseveuk);
}
dbconnect();
$date = 2003-03-02;
var_dump(tips($date));
?
_
Express yourself with cool emoticons http://messenger.msn.co.uk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread John W. Holmes
This is very weird. What are you using to create this code?

If you remove all of the spaces (?) before $query, the code doesn't give
a parse error. It shouldn't give one either way, though, if those are
spaces or a tab before your $query = ... line. 

Even if you remove all of the text and only leave ?, ?, and those
spaces, PHP will spit something like:

Notice: Use of undefined constant   - assumed ' ' in
c:\inetpub\wwwroot\test.php on line 3

So, the fix is to remove those characters and replace them with spaces
or tabs. 

---John W. Holmes...

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

 -Original Message-
 From: David Rice [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 05, 2003 12:34 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] date functions (generates parse error)
 
 
 Sorry, I forgot to add the part at the bottom where I am calling the
 function
 
 =
 
 ?
 function tips($weekstart){
 
   $start = date('Ymd',strtotime($weekstart));
 
   $query = SELECT * FROM Rota WHERE date = $start and date =
 ($start +
 INTERVAL 6 DAY) ORDER BY staffid;
   $result = mysql_query($query);
   while ($row = mysql_fetch_array($result)){
 
   if ( isset ( $tips ) ){
 
   if (isset ( $tips[$row[staffid]] ) ){
 
   $hours = $row[finish] - $row[start];
   $tips[$row[staffid]] =
$tips[$row[staffid]] +
 $hours;
 
   }
 
   else{
 
   $tips[$row[staffid]] = $row[finish] -
$row[start];
 
   }
   }
 
   else{
 
   $tips = array('$row[staffid]' =( $row[finish] -
 $row[start] ) );
 
   }
 
   }
 
   return $tips;
 
 }
 
 function dbconnect(){
   mysql_connect(localhost, filterseveuk, godisadj);
   mysql_select_db(filterseveuk);
 }
 
 dbconnect();
 $date = 2003-03-02;
 
 var_dump(tips($date));
 ?
 
 _
 Express yourself with cool emoticons http://messenger.msn.co.uk
 
 
 --
 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



[PHP-DB] date functions

2003-03-04 Thread David Rice


I am looking for a way to take a date stored in a mysql database... and find 
out the date seven days later.

how would i do this?!

cheers, dave



_
Chat online in real time with MSN Messenger http://messenger.msn.co.uk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  1   2   3   >