Re: [PHP] date problem

2013-01-03 Thread Jim Lucas

On 01/03/2013 01:57 PM, Marc Fromm wrote:

$jes = 01/03/2012;


# php -r "echo 01/03/2012;"
0.00016567263088138

You might want to put quotes around that value so it is actually a 
string and does not get evaluated.


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

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



Re: [PHP] date problem

2013-01-03 Thread Jim Giner

On 1/3/2013 5:22 PM, Marc Fromm wrote:

Thanks Jonathan. I removed the date() syntax function and it works.

From: Jonathan Sundquist [mailto:jsundqu...@gmail.com]
Sent: Thursday, January 03, 2013 2:16 PM
To: Marc Fromm
Cc: Serge Fonville; php-general@lists.php.net
Subject: Re: [PHP] date problem

Marc,

When you take a date and do a strtotime you are converting it to an int which 
you can compare to each other much easier. So for your above example you would 
be best doing.


define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( strtotime($jes) < strtotime(WSOFFBEGIN) )
{
 $error = " MUST begin after " . WSOFFBEGIN . "\n";
}
On Thu, Jan 3, 2013 at 4:12 PM, Marc Fromm 
mailto:marc.fr...@wwu.edu>> wrote:
Thanks for the reply.

Every example on comparing dates in PHP that I found uses the "strtotime" 
function which I am using.  What other type can I use?

When is this example below supposed to work?

// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';
// your second date coming from a mysql database (date fields)
$dateB = '2007-04-14 15:23';
if(strtotime<http://www.php.net/strtotime>($dateA) > 
strtotime<http://www.php.net/strtotime>($dateB)){
 // bla bla
}

Thanks


From: Serge Fonville 
[mailto:serge.fonvi...@gmail.com<mailto:serge.fonvi...@gmail.com>]
Sent: Thursday, January 03, 2013 2:05 PM
To: Marc Fromm
Cc: php-general@lists.php.net<mailto:php-general@lists.php.net>
Subject: Re: [PHP] date problem

Hi.

date returns a string

You should compare a different type for bigger/smaller than

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2013/1/3 Marc Fromm 
mailto:marc.fr...@wwu.edu><mailto:marc.fr...@wwu.edu<mailto:marc.fr...@wwu.edu>>>
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN)) )
 {
 $error = " MUST begin after " . WSOFFBEGIN . "\n";
 }

I cannot figure out why the $error is being assigned inside the if statement, 
since the statement should be false. 01/03/2012 is not less than 09/16/2012.

Marc



And hopefully put quotes around 01/03/2012.

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



RE: [PHP] date problem

2013-01-03 Thread Marc Fromm
Thanks Jonathan. I removed the date() syntax function and it works.

From: Jonathan Sundquist [mailto:jsundqu...@gmail.com]
Sent: Thursday, January 03, 2013 2:16 PM
To: Marc Fromm
Cc: Serge Fonville; php-general@lists.php.net
Subject: Re: [PHP] date problem

Marc,

When you take a date and do a strtotime you are converting it to an int which 
you can compare to each other much easier. So for your above example you would 
be best doing.


define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( strtotime($jes) < strtotime(WSOFFBEGIN) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}
On Thu, Jan 3, 2013 at 4:12 PM, Marc Fromm 
mailto:marc.fr...@wwu.edu>> wrote:
Thanks for the reply.

Every example on comparing dates in PHP that I found uses the "strtotime" 
function which I am using.  What other type can I use?

When is this example below supposed to work?

// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';
// your second date coming from a mysql database (date fields)
$dateB = '2007-04-14 15:23';
if(strtotime<http://www.php.net/strtotime>($dateA) > 
strtotime<http://www.php.net/strtotime>($dateB)){
// bla bla
}

Thanks


From: Serge Fonville 
[mailto:serge.fonvi...@gmail.com<mailto:serge.fonvi...@gmail.com>]
Sent: Thursday, January 03, 2013 2:05 PM
To: Marc Fromm
Cc: php-general@lists.php.net<mailto:php-general@lists.php.net>
Subject: Re: [PHP] date problem

Hi.

date returns a string

You should compare a different type for bigger/smaller than

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2013/1/3 Marc Fromm 
mailto:marc.fr...@wwu.edu><mailto:marc.fr...@wwu.edu<mailto:marc.fr...@wwu.edu>>>
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN)) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}

I cannot figure out why the $error is being assigned inside the if statement, 
since the statement should be false. 01/03/2012 is not less than 09/16/2012.

Marc



Re: [PHP] date problem

2013-01-03 Thread Jonathan Sundquist
Marc,

When you take a date and do a strtotime you are converting it to an int
which you can compare to each other much easier. So for your above example
you would be best doing.


define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( strtotime($jes) < strtotime(WSOFFBEGIN) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}

On Thu, Jan 3, 2013 at 4:12 PM, Marc Fromm  wrote:

> Thanks for the reply.
>
> Every example on comparing dates in PHP that I found uses the "strtotime"
> function which I am using.  What other type can I use?
>
> When is this example below supposed to work?
>
> // your first date coming from a mysql database (date fields)
> $dateA = '2008-03-01 13:34';
> // your second date coming from a mysql database (date fields)
> $dateB = '2007-04-14 15:23';
> if(strtotime<http://www.php.net/strtotime>($dateA) > strtotime<
> http://www.php.net/strtotime>($dateB)){
> // bla bla
> }
>
> Thanks
>
>
> From: Serge Fonville [mailto:serge.fonvi...@gmail.com]
> Sent: Thursday, January 03, 2013 2:05 PM
> To: Marc Fromm
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] date problem
>
> Hi.
>
> date returns a string
>
> You should compare a different type for bigger/smaller than
>
> HTH
>
> Kind regards/met vriendelijke groet,
>
> Serge Fonville
>
> http://www.sergefonville.nl
>
> Convince Microsoft!
> They need to add TRUNCATE PARTITION in SQL Server
>
> https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
>
> 2013/1/3 Marc Fromm mailto:marc.fr...@wwu.edu>>
> I am comparing to dates.
>
> define('WSOFFBEGIN','09/16/2012');
> $jes = 01/03/2012;
>
> if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN))
> )
> {
> $error = " MUST begin after " . WSOFFBEGIN . "\n";
> }
>
> I cannot figure out why the $error is being assigned inside the if
> statement, since the statement should be false. 01/03/2012 is not less than
> 09/16/2012.
>
> Marc
>
>


RE: [PHP] date problem

2013-01-03 Thread Marc Fromm
Thanks for the reply.

Every example on comparing dates in PHP that I found uses the "strtotime" 
function which I am using.  What other type can I use?

When is this example below supposed to work?

// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';
// your second date coming from a mysql database (date fields)
$dateB = '2007-04-14 15:23';
if(strtotime<http://www.php.net/strtotime>($dateA) > 
strtotime<http://www.php.net/strtotime>($dateB)){
// bla bla
}

Thanks


From: Serge Fonville [mailto:serge.fonvi...@gmail.com]
Sent: Thursday, January 03, 2013 2:05 PM
To: Marc Fromm
Cc: php-general@lists.php.net
Subject: Re: [PHP] date problem

Hi.

date returns a string

You should compare a different type for bigger/smaller than

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table

2013/1/3 Marc Fromm mailto:marc.fr...@wwu.edu>>
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN)) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}

I cannot figure out why the $error is being assigned inside the if statement, 
since the statement should be false. 01/03/2012 is not less than 09/16/2012.

Marc



Re: [PHP] date problem

2013-01-03 Thread Ken Robinson

At 04:57 PM 1/3/2013, Marc Fromm wrote:

I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN)) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}

I cannot figure out why the $error is being assigned inside the if 
statement, since the statement should be false. 01/03/2012 is not 
less than 09/16/2012.


You shouldn't be comparing the date strings, but the UNIX timestamp values:

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( strtotime($jes) < strtotime(WSOFFBEGIN) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}

Ken



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



Re: [PHP] date problem

2013-01-03 Thread Serge Fonville
Hi.

date returns a string

You should compare a different type for bigger/smaller than

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


2013/1/3 Marc Fromm 

> I am comparing to dates.
>
> define('WSOFFBEGIN','09/16/2012');
> $jes = 01/03/2012;
>
> if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN))
> )
> {
> $error = " MUST begin after " . WSOFFBEGIN . "\n";
> }
>
> I cannot figure out why the $error is being assigned inside the if
> statement, since the statement should be false. 01/03/2012 is not less than
> 09/16/2012.
>
> Marc
>


Re: [PHP] date problem

2013-01-03 Thread Jonathan Sundquist
1/3/2012 is in fact less then 9/16/2012.


On Thu, Jan 3, 2013 at 3:57 PM, Marc Fromm  wrote:

> I am comparing to dates.
>
> define('WSOFFBEGIN','09/16/2012');
> $jes = 01/03/2012;
>
> if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN))
> )
> {
> $error = " MUST begin after " . WSOFFBEGIN . "\n";
> }
>
> I cannot figure out why the $error is being assigned inside the if
> statement, since the statement should be false. 01/03/2012 is not less than
> 09/16/2012.
>
> Marc
>


Re: [PHP] date problem

2011-04-02 Thread Dan Dan
It seems different php versions have different outputs for this code:

Fedora Core 14 (x86):

first: 01-03-2011 00:00:00
second: 08-03-2011 00:00:00
third: 22-03-2011 00:00:00
fourth: 22-03-2011 00:00:00
fifth: 29-03-2011 00:00:00

Fedora Core11 (x86_64):

first: 31-12-1969 16:00:00
second: 31-12-1969 16:00:00
third: 22-03-2011 00:00:00
fourth: 31-12-1969 16:00:00
fifth: 31-12-1969 16:00:00

However it works if reorder Year and Month like:

echo "first: ".date("d-m-Y H:i:s",strtotime('2011 March first
wednesday'))."\n";
echo "second: ".date("d-m-Y H:i:s",strtotime('2011 March second
wednesday'))."\n";
echo "third: ".date("d-m-Y H:i:s",strtotime('2011 March third
wednesday'))."\n";
echo "fourth: ".date("d-m-Y H:i:s",strtotime('2011 March fourth
wednesday'))."\n";
echo "fifth: ".date("d-m-Y H:i:s",strtotime('2011 March fifth
wednesday'))."\n";

first: 02-03-2011 00:00:00
second: 09-03-2011 00:00:00
third: 16-03-2011 00:00:00
fourth: 23-03-2011 00:00:00
fifth: 30-03-2011 00:00:00

Thanks
-dani


On Sat, Apr 2, 2011 at 1:17 AM, Louis Huppenbauer <
louis.huppenba...@gmail.com> wrote:

> Just try "of March". Worked for me.
>
>
> print "first: ".date("d-m-Y H:i:s",strtotime('first Tuesday of March
> 2011'))."\n";
> print "second: ".date("d-m-Y H:i:s",strtotime('second Tuesday of March
> 2011'))."\n";
> print "third: ".date("d-m-Y H:i:s",strtotime('third Tuesday of March
> 2011'))."\n";
> print "fourth: ".date("d-m-Y H:i:s",strtotime('fourth Tuesday of March
> 2011'))."\n";
> print "fifth: ".date("d-m-Y H:i:s",strtotime('fifth Tuesday of March
> 2011'))."\n";
>
>
> 2011/4/2 Dan Dan :
> > I removed the day (1 before the March), but its still giving the same
> > result, i.e. different days of month with and without the 'first'. Any
> > further help ?
> >
> > print "first Tuesday :".date("d-m-Y H:i:s",strtotime('March 2011
> > Tuesday'))."\n";
> > print "first: ".date("d-m-Y H:i:s",strtotime('March 2011 first
> > Tuesday'))."\n";
> > print "second: ".date("d-m-Y H:i:s",strtotime('March 2011 second
> > Tuesday'))."\n";
> > print "third: ".date("d-m-Y H:i:s",strtotime('March 2011 third
> > Tuesday'))."\n";
> > print "fourth: ".date("d-m-Y H:i:s",strtotime('March 2011 fourth
> > Tuesday'))."\n";
> >
> > first Tuesday :01-03-2011 00:00:00
> > first: 08-03-2011 00:00:00
> > second: 15-03-2011 00:00:00
> > third: 22-03-2011 00:00:00
> > fourth: 29-03-2011 00:00:00
> >
> > Thanks
> > -dani
> >
> >
> >
> > On Fri, Apr 1, 2011 at 9:37 AM, Daniel Brown  wrote:
> >
> >> On Fri, Apr 1, 2011 at 12:35, Dan Dan  wrote:
> >> > Hi Folks,
> >> >
> >> > I am trying to get the day of month for a particular day of week (e.g.
> >> > Tuesday) for the first, second, third, fourth week in a month. The
> code i
> >> > have seems issues in March, but works e.g. in April:
> >> >
> >> > print date("d-m-Y H:i:s",strtotime('1 March 2011 Tuesday'));
> >> >>> 01-03-2011 00:00:00
> >> >
> >> > print date("d-m-Y H:i:s",strtotime('1 March 2011 first Tuesday'));
> >> >>> 08-03-2011 00:00:00
> >> >
> >> > While in April, I have
> >> >
> >> > print date("d-m-Y H:i:s",strtotime('1 April 2011 Tuesday'));
> >> >>> 05-04-2011 00:00:00
> >> >
> >> > print date("d-m-Y H:i:s",strtotime('1 April 2011 first Tuesday'));
> >> >>> 05-04-2011 00:00:00
> >> >
> >> > Could someone help whats wrong with the technique i am trying to find
> >> that
> >> > day of month. Is there any better way ?
> >>
> >> Because you're combining the date with the day of the week.  It so
> >> happens that 1 March was a Tuesday, but today - 1 April - is a Friday.
> >>  Pick one or the other, not both.
> >>
> >> --
> >> 
> >> Network Infrastructure Manager
> >> http://www.php.net/
> >>
> >
>


Re: [PHP] date problem

2011-04-02 Thread Louis Huppenbauer
Just try "of March". Worked for me.


print "first: ".date("d-m-Y H:i:s",strtotime('first Tuesday of March
2011'))."\n";
print "second: ".date("d-m-Y H:i:s",strtotime('second Tuesday of March
2011'))."\n";
print "third: ".date("d-m-Y H:i:s",strtotime('third Tuesday of March
2011'))."\n";
print "fourth: ".date("d-m-Y H:i:s",strtotime('fourth Tuesday of March
2011'))."\n";
print "fifth: ".date("d-m-Y H:i:s",strtotime('fifth Tuesday of March
2011'))."\n";


2011/4/2 Dan Dan :
> I removed the day (1 before the March), but its still giving the same
> result, i.e. different days of month with and without the 'first'. Any
> further help ?
>
> print "first Tuesday :".date("d-m-Y H:i:s",strtotime('March 2011
> Tuesday'))."\n";
> print "first: ".date("d-m-Y H:i:s",strtotime('March 2011 first
> Tuesday'))."\n";
> print "second: ".date("d-m-Y H:i:s",strtotime('March 2011 second
> Tuesday'))."\n";
> print "third: ".date("d-m-Y H:i:s",strtotime('March 2011 third
> Tuesday'))."\n";
> print "fourth: ".date("d-m-Y H:i:s",strtotime('March 2011 fourth
> Tuesday'))."\n";
>
> first Tuesday :01-03-2011 00:00:00
> first: 08-03-2011 00:00:00
> second: 15-03-2011 00:00:00
> third: 22-03-2011 00:00:00
> fourth: 29-03-2011 00:00:00
>
> Thanks
> -dani
>
>
>
> On Fri, Apr 1, 2011 at 9:37 AM, Daniel Brown  wrote:
>
>> On Fri, Apr 1, 2011 at 12:35, Dan Dan  wrote:
>> > Hi Folks,
>> >
>> > I am trying to get the day of month for a particular day of week (e.g.
>> > Tuesday) for the first, second, third, fourth week in a month. The code i
>> > have seems issues in March, but works e.g. in April:
>> >
>> > print date("d-m-Y H:i:s",strtotime('1 March 2011 Tuesday'));
>> >>> 01-03-2011 00:00:00
>> >
>> > print date("d-m-Y H:i:s",strtotime('1 March 2011 first Tuesday'));
>> >>> 08-03-2011 00:00:00
>> >
>> > While in April, I have
>> >
>> > print date("d-m-Y H:i:s",strtotime('1 April 2011 Tuesday'));
>> >>> 05-04-2011 00:00:00
>> >
>> > print date("d-m-Y H:i:s",strtotime('1 April 2011 first Tuesday'));
>> >>> 05-04-2011 00:00:00
>> >
>> > Could someone help whats wrong with the technique i am trying to find
>> that
>> > day of month. Is there any better way ?
>>
>>     Because you're combining the date with the day of the week.  It so
>> happens that 1 March was a Tuesday, but today - 1 April - is a Friday.
>>  Pick one or the other, not both.
>>
>> --
>> 
>> Network Infrastructure Manager
>> http://www.php.net/
>>
>

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



Re: [PHP] date problem

2011-04-01 Thread Dan Dan
I removed the day (1 before the March), but its still giving the same
result, i.e. different days of month with and without the 'first'. Any
further help ?

print "first Tuesday :".date("d-m-Y H:i:s",strtotime('March 2011
Tuesday'))."\n";
print "first: ".date("d-m-Y H:i:s",strtotime('March 2011 first
Tuesday'))."\n";
print "second: ".date("d-m-Y H:i:s",strtotime('March 2011 second
Tuesday'))."\n";
print "third: ".date("d-m-Y H:i:s",strtotime('March 2011 third
Tuesday'))."\n";
print "fourth: ".date("d-m-Y H:i:s",strtotime('March 2011 fourth
Tuesday'))."\n";

first Tuesday :01-03-2011 00:00:00
first: 08-03-2011 00:00:00
second: 15-03-2011 00:00:00
third: 22-03-2011 00:00:00
fourth: 29-03-2011 00:00:00

Thanks
-dani



On Fri, Apr 1, 2011 at 9:37 AM, Daniel Brown  wrote:

> On Fri, Apr 1, 2011 at 12:35, Dan Dan  wrote:
> > Hi Folks,
> >
> > I am trying to get the day of month for a particular day of week (e.g.
> > Tuesday) for the first, second, third, fourth week in a month. The code i
> > have seems issues in March, but works e.g. in April:
> >
> > print date("d-m-Y H:i:s",strtotime('1 March 2011 Tuesday'));
> >>> 01-03-2011 00:00:00
> >
> > print date("d-m-Y H:i:s",strtotime('1 March 2011 first Tuesday'));
> >>> 08-03-2011 00:00:00
> >
> > While in April, I have
> >
> > print date("d-m-Y H:i:s",strtotime('1 April 2011 Tuesday'));
> >>> 05-04-2011 00:00:00
> >
> > print date("d-m-Y H:i:s",strtotime('1 April 2011 first Tuesday'));
> >>> 05-04-2011 00:00:00
> >
> > Could someone help whats wrong with the technique i am trying to find
> that
> > day of month. Is there any better way ?
>
> Because you're combining the date with the day of the week.  It so
> happens that 1 March was a Tuesday, but today - 1 April - is a Friday.
>  Pick one or the other, not both.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>


Re: [PHP] date problem

2011-04-01 Thread Daniel Brown
On Fri, Apr 1, 2011 at 12:35, Dan Dan  wrote:
> Hi Folks,
>
> I am trying to get the day of month for a particular day of week (e.g.
> Tuesday) for the first, second, third, fourth week in a month. The code i
> have seems issues in March, but works e.g. in April:
>
> print date("d-m-Y H:i:s",strtotime('1 March 2011 Tuesday'));
>>> 01-03-2011 00:00:00
>
> print date("d-m-Y H:i:s",strtotime('1 March 2011 first Tuesday'));
>>> 08-03-2011 00:00:00
>
> While in April, I have
>
> print date("d-m-Y H:i:s",strtotime('1 April 2011 Tuesday'));
>>> 05-04-2011 00:00:00
>
> print date("d-m-Y H:i:s",strtotime('1 April 2011 first Tuesday'));
>>> 05-04-2011 00:00:00
>
> Could someone help whats wrong with the technique i am trying to find that
> day of month. Is there any better way ?

Because you're combining the date with the day of the week.  It so
happens that 1 March was a Tuesday, but today - 1 April - is a Friday.
 Pick one or the other, not both.

-- 

Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Date Problem with \n

2007-08-13 Thread Richard Lynch
On Mon, August 13, 2007 12:50 pm, Kevin Murphy wrote:
> Small issue with formatting a date. If I type in this:
>
> echo date("g:i:s a \o\n l F j, Y");
>
> the "n" character in the word "on" doesn't appear, but instead what I
> get is a new line in the source code. If I type it as:
>
> echo date("g:i:s a \on l F j, Y");
>
> I get the number 8 (current month) where the n is supposed to be.
>
> Is there any way to get an "n" in there?

As noted, apostrophes will work in this case.

If you need to embed a variable, however, you may want to re-read this
from the manual a couple times:


"You can prevent a recognized character in the format string from
being expanded by escaping it with a preceding backslash. If the
character with a backslash is already a special sequence, you may need
to also escape the backslash."

So, for example:

date("g:i:s a \o\\n l F j, Y");

Here's what happens:

PHP's string parser "eats" the "\\" and turns it into a single
back-slash: "\"

*THEN* you have "\n" being passed to the C date() function, which then
"eats" the "\n" and says:
This is then not the "n" for "Numeric representation of a month,
without leading zeros" but just a regular old "n" as text.

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

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



Re: [PHP] Date Problem with \n

2007-08-13 Thread Jim Lucas

Kevin Murphy wrote:

Small issue with formatting a date. If I type in this:

echo date("g:i:s a \o\n l F j, Y");

the "n" character in the word "on" doesn't appear, but instead what I 
get is a new line in the source code. If I type it as:


echo date("g:i:s a \on l F j, Y");

I get the number 8 (current month) where the n is supposed to be.

Is there any way to get an "n" in there?



Use single quotes, then your \n will not be converted to a NL char

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] date() problem

2005-07-07 Thread Ryan A
Hey Richard,

Thanks, you've pulled my butt outa the fire again :-)

Cheers,
Ryan

On 7/6/2005 10:59:36 PM, Richard Lynch ([EMAIL PROTECTED]) wrote:
> On Wed, July 6, 2005 12:07 pm, Ryan A said:
> >
> I'm confused, this should give me the age as 17 instead of 16...but it
> > does
> > not...any ideas why?
> >
> >  > $age="1988-07-06";
> >
> > $day1=strtotime($age);
> > $day2 = strtotime(date("Y-m-d"));
> > $dif_s = ($day2-$day1);
> > $dif_d = ($dif_s/60/60/24);
> > $age = floor(($dif_d/365.24));
> >
> > echo $age;
> > ?>
> 
> 365.24 is an appoximation.
> 
> Sooner or later, it's
> gonna bit you in the butt.
> 
> If you want somebody's age accurately, you're probably going to have to
> do
> it the hard way.
> 
> Something like this might work:
> 
>  $DOB = "1988-07-06";
> $now = date('Y-m-d');
> list($by, $bm, $bd) = explode('-', $DOB);
> list($ny, $nm, $nd) = explode('-', $now);
> $age = $ny - $by;
> if ($age){
> if ($bm < $nm){
> // do nothing, they were born before this month
> // so subtracting the years is correct
> }
> elseif ($nm < $bm){
> $age--; //They were born in a later month, so not quite a year yet
> }
> else{
> //They were born this month. Count the days.
> if ($bd < $nd){
> //Do nothing.  They were born before this date.
  }
  elseif ($nd < $bd){
$age--; //They were born later this month, so not quite a year yet
  }
  else{
//It's their birthday! Go ahead and count it as a year,
//unless you want to futz with the hour of their birth...
  }
}
  }
  if (!$age){
//Do whatever you want with children less than 1 year old...
//return it as "X months" or just call it "infant" or pretend they're 1
//or whatever.
//Maybe even just use $age (which is 0) and call it done.
  }
?>

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] date() problem

2005-07-07 Thread Kristen G. Thorson

Philip Hallstrom wrote:

of leap years between the two dates.  Leap years occur every 4 years, 
and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 
7/6/05 and



Just to nitpick... :-)

http://en.wikipedia.org/wiki/Leap_year

The Gregorian calendar adds an extra day to February, making it 29 
days long, in years where the quotient has no remainder when divided 
by 4, excluding years where the quotient has no remainder when divided 
by 100, but including years where the quotient has no remainder when 
divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 
1900 and 2100 are not.





Touche!

One more reason not to use the OP's method but rather the one posted by 
Richard Lynch.



kgt

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



Re: [PHP] date() problem

2005-07-06 Thread Edward Vermillion


On Jul 6, 2005, at 5:31 PM, Edward Vermillion wrote:



On Jul 6, 2005, at 5:17 PM, Edward Vermillion wrote:



On Jul 6, 2005, at 4:44 PM, Philip Hallstrom wrote:

of leap years between the two dates.  Leap years occur every 4 
years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 
and 7/6/05 and


Just to nitpick... :-)

http://en.wikipedia.org/wiki/Leap_year

The Gregorian calendar adds an extra day to February, making it 29 
days long, in years where the quotient has no remainder when divided 
by 4, excluding years where the quotient has no remainder when 
divided by 100, but including years where the quotient has no 
remainder when divided by 400. So 1996, 2000, and 2400 are leap 
years but 1800, 1899, 1900 and 2100 are not.


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




I always wondered what kind of drugs those guys were on when they 
came up with the leap-year system... :P


One interesting side note to the op's problem, since I'm not going to 
be able to do anything else till I figure this out now..., if one of 
the dates is a leap year the 365.25 works fine, which make me wonder 
how the strtotime() function is working... or maybe that's what it's 
supposed to do... ;)


But then, even if I do figure this out, it's still going to tell me 
I'm only 35... which is a bit off...


As usual Richard's way is probably the best for any "real world" age 
deduction. ;)


Well, I'll let you test through it but it seems to work with the two or 
three dates I ran through...


$realAge = floor(($day2-$day1-($spd*floor((($day2 - 
$day1)/$sy)/4)))/$sy);


print $realAge;

exit;
?>

I left $sy and $spd in so you could see where those values were coming 
from
but you could just as well stick the numbers in for the vars and only 
have $day1

and $day2 hanging around.

of course it only works on most systems with "birth dates" before the 
epoch... :P



Edward Vermillion
[EMAIL PROTECTED]

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



Re: [PHP] date() problem

2005-07-06 Thread Edward Vermillion


On Jul 6, 2005, at 5:17 PM, Edward Vermillion wrote:



On Jul 6, 2005, at 4:44 PM, Philip Hallstrom wrote:

of leap years between the two dates.  Leap years occur every 4 
years, and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 
and 7/6/05 and


Just to nitpick... :-)

http://en.wikipedia.org/wiki/Leap_year

The Gregorian calendar adds an extra day to February, making it 29 
days long, in years where the quotient has no remainder when divided 
by 4, excluding years where the quotient has no remainder when 
divided by 100, but including years where the quotient has no 
remainder when divided by 400. So 1996, 2000, and 2400 are leap years 
but 1800, 1899, 1900 and 2100 are not.


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




I always wondered what kind of drugs those guys were on when they came 
up with the leap-year system... :P


One interesting side note to the op's problem, since I'm not going to 
be able to do anything else till I figure this out now..., if one of 
the dates is a leap year the 365.25 works fine, which make me wonder 
how the strtotime() function is working... or maybe that's what it's 
supposed to do... ;)


But then, even if I do figure this out, it's still going to tell me I'm 
only 35... which is a bit off...


As usual Richard's way is probably the best for any "real world" age 
deduction. ;)



Edward Vermillion
[EMAIL PROTECTED]

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



Re: [PHP] date() problem

2005-07-06 Thread Edward Vermillion


On Jul 6, 2005, at 4:44 PM, Philip Hallstrom wrote:

of leap years between the two dates.  Leap years occur every 4 years, 
and 17 / 4 = 4.25, so there were 4 leap years between 7/6/88 and 
7/6/05 and


Just to nitpick... :-)

http://en.wikipedia.org/wiki/Leap_year

The Gregorian calendar adds an extra day to February, making it 29 
days long, in years where the quotient has no remainder when divided 
by 4, excluding years where the quotient has no remainder when divided 
by 100, but including years where the quotient has no remainder when 
divided by 400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 
1900 and 2100 are not.


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




I always wondered what kind of drugs those guys were on when they came 
up with the leap-year system... :P


One interesting side note to the op's problem, since I'm not going to 
be able to do anything else till I figure this out now..., if one of 
the dates is a leap year the 365.25 works fine, which make me wonder 
how the strtotime() function is working... or maybe that's what it's 
supposed to do... ;)


Edward Vermillion
[EMAIL PROTECTED]

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



Re: [PHP] date() problem

2005-07-06 Thread Philip Hallstrom
of leap years between the two dates.  Leap years occur every 4 years, and 17 
/ 4 = 4.25, so there were 4 leap years between 7/6/88 and 7/6/05 and


Just to nitpick... :-)

http://en.wikipedia.org/wiki/Leap_year

The Gregorian calendar adds an extra day to February, making it 29 days 
long, in years where the quotient has no remainder when divided by 4, 
excluding years where the quotient has no remainder when divided by 100, 
but including years where the quotient has no remainder when divided by 
400. So 1996, 2000, and 2400 are leap years but 1800, 1899, 1900 and 2100 
are not.


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



Re: [PHP] date() problem

2005-07-06 Thread Edward Vermillion


On Jul 6, 2005, at 3:59 PM, Richard Lynch wrote:


365.24 is an appoximation.

Sooner or later, it's gonna bit you in the butt.

If you want somebody's age accurately, you're probably going to have 
to do

it the hard way.

Something like this might work:

  $age--; //They were born in a later month, so not quite a year 
yet

}
else{
  //They were born this month. Count the days.
  if ($bd < $nd){
//Do nothing.  They were born before this date.
  }
  elseif ($nd < $bd){
$age--; //They were born later this month, so not quite a year 
yet

  }
  else{
//It's their birthday! Go ahead and count it as a year,
//unless you want to futz with the hour of their birth...
  }
}
  }
  if (!$age){
//Do whatever you want with children less than 1 year old...
//return it as "X months" or just call it "infant" or pretend 
they're 1

//or whatever.
//Maybe even just use $age (which is 0) and call it done.
  }
?>


Actually, I was thinking it could be done inside a simple formula since 
his original "formula" works on the "leap" years, ie. years divisible 
by four. I guess the trick would be figuring out the actual seconds in 
a year and doing most of the calculations on the unix timestamp. 
Something is tickling the back of my brain on this but I can't see it 
just yet. Eh...


Edward Vermillion
[EMAIL PROTECTED]

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



Re: [PHP] date() problem

2005-07-06 Thread Kristen G. Thorson

Ryan A wrote:


Hi,

I'm confused, this should give me the age as 17 instead of 16...but it does
not...any ideas why?



Thanks,
Ryan

 




Subtracting the timestamps gives you 536457600 seconds, which is 
correct, but ( $dif_s / 60 / 60 / 24 ) gives you the actual number of 
days between these two dates.  We say on *average* there are 365.25 days 
in a year, so 17 years (the correct age in years between these two 
dates) has about 17 * 365.25 = 6209.25 days.  In actuality, there are 
6209 days between these two dates.  This seems close, but note that


6209.25 / 365.25 = 17

but

6209 / 365.25 = 16.9993155

And of course floor on 16.9993155 is still just 16.  I don't think you 
can accurately calculate dates in this way without calculating the 
actual number of leap years between the two dates.  Leap years occur 
every 4 years, and 17 / 4 = 4.25, so there were 4 leap years between 
7/6/88 and 7/6/05 and therefore 365 * 17 + 4 = 6209 days, the actual 
number of days between these two dates.  But note that


( 6209 - 4 ) / 365 = 17,

which is correct.  If you subtract the number of extra days due to leap 
years, then there are precisely 365 days in each year.


It boils down to the fact that though there are on *average* 365.25 days 
in a calendar year, there are never *actually* 365.25 days in a calendar 
year.  There are only either 365 or 366.



kgt

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



Re: [PHP] date() problem

2005-07-06 Thread Richard Lynch
On Wed, July 6, 2005 12:07 pm, Ryan A said:
> I'm confused, this should give me the age as 17 instead of 16...but it
> does
> not...any ideas why?
>
>  $age="1988-07-06";
>
> $day1=strtotime($age);
> $day2 = strtotime(date("Y-m-d"));
> $dif_s = ($day2-$day1);
> $dif_d = ($dif_s/60/60/24);
> $age = floor(($dif_d/365.24));
>
> echo $age;
> ?>

365.24 is an appoximation.

Sooner or later, it's gonna bit you in the butt.

If you want somebody's age accurately, you're probably going to have to do
it the hard way.

Something like this might work:



-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] date() problem

2005-07-06 Thread Edward Vermillion


On Jul 6, 2005, at 2:35 PM, Edward Vermillion wrote:



On Jul 6, 2005, at 2:07 PM, Ryan A wrote:


Hi,

I'm confused, this should give me the age as 17 instead of 16...but 
it does

not...any ideas why?



Thanks,
Ryan

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




If I change $day2 to =time(); instead of strtotime() I get 17. Could 
be some weirdness going on with using date()?.




Actually it's in the math... With the numbers you have here $dif_d 
would need to be 6209.24/25 to get up to 17, so the fault lies in the 
365.24/25 assumption for a day. Don't ask me how to get around it... it 
makes my head hurt. :D



Edward Vermillion
[EMAIL PROTECTED]

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



Re: [PHP] date() problem

2005-07-06 Thread Edward Vermillion


On Jul 6, 2005, at 2:07 PM, Ryan A wrote:


Hi,

I'm confused, this should give me the age as 17 instead of 16...but it 
does

not...any ideas why?



Thanks,
Ryan

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




If I change $day2 to =time(); instead of strtotime() I get 17. Could be 
some weirdness going on with using date()?.



Edward Vermillion
[EMAIL PROTECTED]

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



Re: [PHP] Date problem?

2004-12-22 Thread Sebastian
try +one month
  - Original Message - 
  From: PHP 
  To: php 
  Sent: Wednesday, December 22, 2004 6:38 PM
  Subject: [PHP] Date problem?


  echo date('F',strtotime("next month"));

  This is printing February right now. Does this sound right or is this a but 
in strtotime()? is "next month" a valid parameter?

  and yes, I am sure our server is set to December(todays date).

  echo date('F',strtotime("last month"));
  Does give me November as it should



--


  No virus found in this outgoing message.
  Checked by AVG Anti-Virus.
  Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004




--


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

Re: [PHP] Date problem?

2004-12-22 Thread PHP
Ok,
I was using the download version of the manual and it didn't have any user 
comments on this, but the online one does.


Hi,
I did use the +1 month, but I was just curious as to what was up.


Try this instead...
 echo date('F',strtotime("+1 month"));
read through the user comments at...
http://us2.php.net/manual/en/function.strtotime.php
there are some things pertaining to your situtation
-Chris
On Wed, 22 Dec 2004 15:38:38 -0800, PHP <[EMAIL PROTECTED]> wrote:
echo date('F',strtotime("next month"));
This is printing February right now. Does this sound right or is this a 
but
in strtotime()? is "next month" a valid parameter?

and yes, I am sure our server is set to December(todays date).
echo date('F',strtotime("last month"));
Does give me November as it should
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004
--
PHP General 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 Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004
--
PHP General 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 Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Date problem?

2004-12-22 Thread PHP
Hi,
I did use the +1 month, but I was just curious as to what was up.


Try this instead...
 echo date('F',strtotime("+1 month"));
read through the user comments at...
http://us2.php.net/manual/en/function.strtotime.php
there are some things pertaining to your situtation
-Chris
On Wed, 22 Dec 2004 15:38:38 -0800, PHP <[EMAIL PROTECTED]> wrote:
echo date('F',strtotime("next month"));
This is printing February right now. Does this sound right or is this a 
but
in strtotime()? is "next month" a valid parameter?

and yes, I am sure our server is set to December(todays date).
echo date('F',strtotime("last month"));
Does give me November as it should
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004
--
PHP General 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 Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Date problem?

2004-12-22 Thread Christopher Fulton
Try this instead...
  echo date('F',strtotime("+1 month")); 

read through the user comments at...
http://us2.php.net/manual/en/function.strtotime.php

there are some things pertaining to your situtation
-Chris


On Wed, 22 Dec 2004 15:38:38 -0800, PHP <[EMAIL PROTECTED]> wrote:
>  
> echo date('F',strtotime("next month")); 
>   
> This is printing February right now. Does this sound right or is this a but
> in strtotime()? is "next month" a valid parameter? 
>   
> and yes, I am sure our server is set to December(todays date). 
>   
> echo date('F',strtotime("last month")); 
> Does give me November as it should 
>   
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.298 / Virus Database: 265.6.4 - Release Date: 12/22/2004
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] date problem

2003-09-24 Thread Curt Zirzow
* Thus wrote Shaun ([EMAIL PROTECTED]):
> Hi,
> 
> Why does the following code print '00', surely it should print '08', I'm
> baffled!
> 
> date("H", mktime(8, 0, 0, 0, 0, 0));



kinda wierd, I say blame it on the y1969 bug.

make sure your day and month don't go backwards, that seems to be
what the problem is.  


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



RE: [PHP] Date problem

2003-06-23 Thread Dan Joseph
Hi,

That looks like a unix timestamp.  Try this:

Echo date("Y/m/d h:i:s", "1056044640");

www.php.net/date

Check that link to see the lettering codes and the syntax, I
might be off on what I typed up there, but you'll get the concept.

-Dan Joseph

-Original Message-
From: Logan McKinley [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 23, 2003 5:06 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Date problem

I am storing dates in an Access database in a field with a "Date/Time"
Type
the date is being generated using date("n/d/Y  h:i a").  It appears to
be
stored in Access correctly but when I output it to the page using PHP it
seems to be changing.  It is being stored in the database as "6/19/2003
1:44:00 PM" but being displayed on the page as "1056044640"
Thanks in advance,
~Logan



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


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



Re: [PHP] Date problem

2003-06-23 Thread Mike Migurski
>I am storing dates in an Access database in a field with a "Date/Time" Type
>the date is being generated using date("n/d/Y  h:i a").  It appears to be
>stored in Access correctly but when I output it to the page using PHP it
>seems to be changing.  It is being stored in the database as "6/19/2003
>1:44:00 PM" but being displayed on the page as "1056044640"
>Thanks in advance,

That's a timestamp - it's the number of seconds since the Unix Epoch
(1/1/1970 GMT), and you can read up about conversion here: php.net/date

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



Re: [PHP] Date Problem - Last Day Of Month

2003-03-31 Thread Kevin Stone

- Original Message -
From: "Vinesh Hansjee" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 31, 2003 6:55 AM
Subject: [PHP] Date Problem - Last Day Of Month


> Hi there, can anyone tell me how to fix my code so that on the last day of
> the month, my code doesn't repeat the months...
> What the code suppose to do is, makes a drop down box from which you can
> select the month, and if its the current month
> the box is already selected.
>
> 
>
> 
> for ($i=1; $i<=12; $i++) {
>  if ($i == date("m")) {
>   print "" .
> date("F",mktime(0,0,0,$i,date("d"),date("Y"))) . "";
>  } else {
>   print "" .
> date("F",mktime(0,0,0,$i,date("d"),date("Y"))) . "";
>  }
> }
>
> ?>
>
> 
>
> Thanks
> Vinesh


Vinesh, there's a fundemental flaw in your logic.  The date("d") input will
fail to produce a reliable list if it is executed on any day after the 28th
of the month.  Since today is the 31st obviously this is going to cause some
problems becuase any month that ends on the 30th or earlier will return plus
one the month.  So February will return March, April willl return May, and
so on.  If you wait until tommorrow (the 1st) your function will magically
work.  :)

One way to fix this is to build your own array of month names and reference
that instead of using the date() function.

$months = array(1=>"January", 2=>"February", 3=>"March", 4=>"April",
5="May", 6=> ... and so on...);

for($i=1; $i<=12; $i++)
{
$selected = "";
if ($i == date("m"));{$selected = "SELECTED";}
echo "\n";
}

HTH,
Kevin




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



Re: [PHP] Date Problem - Last Day Of Month

2003-03-31 Thread Daniel Guerrier
change 
for ($i=1; $i<=12; $i++)

to


for ($i=1; $i<12; $i++)
--- Vinesh Hansjee <[EMAIL PROTECTED]> wrote:
> Hi there, can anyone tell me how to fix my code so
> that on the last day of
> the month, my code doesn't repeat the months...
> What the code suppose to do is, makes a drop down
> box from which you can
> select the month, and if its the current month
> the box is already selected.
> 
> 
> 
>  
> for ($i=1; $i<=12; $i++) {
>  if ($i == date("m")) {
>   print "" .
> date("F",mktime(0,0,0,$i,date("d"),date("Y"))) .
> "";
>  } else {
>   print "" .
> date("F",mktime(0,0,0,$i,date("d"),date("Y"))) .
> "";
>  }
> }
> 
> ?>
> 
> 
> 
> Thanks
> Vinesh
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

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



Re: [PHP] Date Problem - Last Day Of Month

2003-03-31 Thread Liam Gibbs
> Hi there, can anyone tell me how to fix my code so that on the last day of
> the month, my code doesn't repeat the months...

I'm not sure what you mean by this, but I can be a moron on this list
sometimes and the clear answer usually comes to me about 2 seconds after I
hit the send button. Do you mean that you don't want any months in the
SELECT control when it's the last of the month? Or you don't want the
SELECTED attribute in the OPTION tags? As far as I can tell, you're not
repeating any months, but you're only listing them once.

Try this (and IMHO a *slight* *slight* improvement in clarity, but again,
that's my HO):


" . date("F",mktime(0,0,0,$counter,date("d"),date("Y"))) .
"";
}
}


I adjusted it so that you only print out the SELECTED attribute if it's the
current month, and I called $i as $counter, because, to me anyway, it makes
it clearer what is the $counter. If $i works for you, though, there's
nothing wrong with that, and it's not that it's unclear anyway, what with it
in the FOR loop only a few lines earlier. (I'll shut up now about $counter.)

Anyway, I added a comparison above that said if the current date is less
than the last day of the month, then print SELECTED. That's assuming I have
your question right in that you don't want to select the current month if
it's the last day of that month. Otherwise, if I'm wrong, you can take that
comparison and put it just about anywhere.

Help? Doesn't? Am I a complete goof?


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



Re: [PHP] date problem

2003-02-27 Thread Lowell Allen
> From: "Alexander Tsonev" <[EMAIL PROTECTED]>
> 
> Hello,
> I would ask you a question about date type
> if I have a variable from date type ($newdate) such as 2003-02-17
> how can I separate $newdate into 3 different variables? I want to create
> such variables:
> $day=17
> $month=2
> $year=2003
> I searched a lot, but I didn't find how to do this.
> I'll be very happy if someone helps!
> 

list($year, $month, $day) = explode("-", $newdate);

--
Lowell Allen


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



RE: [PHP] Date problem

2002-12-31 Thread John W. Holmes
> Our school holds many seminars of varying durations and dates. I want
to
> make a page which says "What's on today" which will show all the
seminars
> that are on today. However the entry in the database will show two
fields
> "Commencing Date" and "Ending date".
> 
> Is there a routine in PHP I can use to find if today's date fits
between
> the commencing date and the ending date?

SELECT * FROM table WHERE CURRENT_DATE BETWEEN commence_date AND
ending_date

---John W. Holmes...

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



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




Re: [PHP] Date problem

2002-12-31 Thread Rick Widmer
At 05:23 PM 12/31/02 +0800, Denis L. Menezes wrote:

Hello friends.

Is there a routine in PHP I can use to find if today's date fits between 
the commencing date and the ending date?


SELECT * FROM Table WHERE NOW() >= StartDate AND NOW() <= EndDate

Rick





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




Re: [PHP] Date problem

2002-12-03 Thread James Coates
At 19:32 03/12/2002 +0800, Jason Wong wrote:


Assuming the column holding the the birthday is called 'birthday':


[snip]

Many thanks!


> * give me actors whose birthdays fall between two dates (ie: Aries)

This one is easy, use the BETWEEN clause in your SELECT statement. Consult
manual for details.


Ignoring the year, obviously, to get my Aries. :-)

James.

--
--
[EMAIL PROTECTED] - http://www.affection.net/~jamesc/ - [+33] 6 79 02 08 99


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




Re: [PHP] Date problem

2002-12-03 Thread Jason Wong
On Tuesday 03 December 2002 18:29, James Coates wrote:

> Perhaps you could throw a clue my way, in that case.

> I have an actor database (mySQL again) which has actor dates of birth in
> '-MM-DD' format. I want to be able to query against that ignoring the
> year:
>
> * give me actors who have birthdays in the next five days

Assuming the column holding the the birthday is called 'birthday':

a) you have to work out the date in 5 days time:

  DATE_ADD(CURRENT_DATE, INTERVAL 5 DAY)

b) You have to transform the birthdays so that they are for the current year 
(so instead of 1981-04-01 it becomes 2002-04-01)

CONCAT(YEAR(CURRENT_DATE), '-', MONTH(birthday), '-', 
DAYOFMONTH(birthday))

c) Combine both into your query:

  SELECT *,
 CONCAT(YEAR(CURRENT_DATE), '-', MONTH(birthday), '-', 
DAYOFMONTH(birthday)) as current_birthday
   FROM table
   WHERE current_birthday >= CURRENT_DATE
 AND current_birthday <= DATE_ADD(CURRENT_DATE, INTERVAL 5 DAY)

** Untested ** use with extreme caution.

> * give me actors whose birthdays fall between two dates (ie: Aries)

This one is easy, use the BETWEEN clause in your SELECT statement. Consult 
manual for details.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Intuition, however illogical, is recognized as a command prerogative.
-- Kirk, "Obsession", stardate 3620.7
*/


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




RE: [PHP] Date problem

2002-12-03 Thread James Coates
At 18:44 02/12/2002 -0500, John W. Holmes wrote:


> Can you help me for this ?

Yeah, I already did:


Perhaps you could throw a clue my way, in that case.

I have an actor database (mySQL again) which has actor dates of birth in 
'-MM-DD' format. I want to be able to query against that ignoring the year:

* give me actors who have birthdays in the next five days
* give me actors whose birthdays fall between two dates (ie: Aries)

I've got pretty much everything else working but this one's *really* 
playing with my head. :-( I know I should've employed  a db engineer! :)

James.



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



RE: [PHP] Date problem

2002-12-02 Thread John W. Holmes
> Thanks for this,
> I understand how to update in date in database, but I need when I get
date
> from database to increase or decrease before to save in database.
> 
> Can you help me for this ?

Yeah, I already did:

> > You can select out the date you have now, use strtotime() to make it
> > into a unix timestamp (which PHP works with), and date() to format
it
> > however you want. If the user approves the new date, you can
reformat
> > the unix timestamp back to a -MM-DD format with date() or use
> > FROM_UNIXTIME() in your query to insert/update the new date into the
> > database...

---John Holmes...



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




Re: [PHP] Date problem

2002-12-02 Thread Rosen

Thanks for this,
I understand how to update in date in database, but I need when I get date
from database to increase or decrease before to save in database.

Can you help me for this ?

"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
001501c2999b$d24a71f0$7c02a8c0@coconut">news:001501c2999b$d24a71f0$7c02a8c0@coconut...
> > I want to get date from database, to increment ot decrement it with
> some
> > days, to show the date and after thath
> > if user confirm it to save it to database.
>
> There are a ton of ways you can do it. You can select the date and it's
> inc/dec value in the same statement:
>
> SELECT datecol, datecol + INTERVAL 1 DAY FROM yourtable WHERE ...
>
> Display whatever you need, if the user agrees to the new day, then issue
> an update query:
>
> UPDATE yourtable SET datecol = datecol + INTERVAL 1 DAY WHERE ...
>
> To make those queries dynamic, you can replace the '1' with a variable
> and assign it's value in PHP to either -1, 1, 2, 3, etc...
>
> $inc = -1;
>
> UPDATE yourtable SET datecol = datecol + INTERVAL $inc DAY WHERE ...
>
> Or...
>
> You can select out the date you have now, use strtotime() to make it
> into a unix timestamp (which PHP works with), and date() to format it
> however you want. If the user approves the new date, you can reformat
> the unix timestamp back to a -MM-DD format with date() or use
> FROM_UNIXTIME() in your query to insert/update the new date into the
> database...
>
> ---John Holmes...
>
>



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




RE: [PHP] Date problem

2002-12-01 Thread John W. Holmes
> I want to get date from database, to increment ot decrement it with
some
> days, to show the date and after thath
> if user confirm it to save it to database.

There are a ton of ways you can do it. You can select the date and it's
inc/dec value in the same statement:

SELECT datecol, datecol + INTERVAL 1 DAY FROM yourtable WHERE ...

Display whatever you need, if the user agrees to the new day, then issue
an update query:

UPDATE yourtable SET datecol = datecol + INTERVAL 1 DAY WHERE ...

To make those queries dynamic, you can replace the '1' with a variable
and assign it's value in PHP to either -1, 1, 2, 3, etc...

$inc = -1;

UPDATE yourtable SET datecol = datecol + INTERVAL $inc DAY WHERE ... 

Or...

You can select out the date you have now, use strtotime() to make it
into a unix timestamp (which PHP works with), and date() to format it
however you want. If the user approves the new date, you can reformat
the unix timestamp back to a -MM-DD format with date() or use
FROM_UNIXTIME() in your query to insert/update the new date into the
database...

---John Holmes...



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




Re: [PHP] Date problem

2002-12-01 Thread Rosen
It's in -MM-YY

"Justin French" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> on 02/12/02 9:59 AM, Rosen ([EMAIL PROTECTED]) wrote:
>
> > I want to get date from database, to increment ot decrement it with some
> > days, to show the date and after thath
> > if user confirm it to save it to database.
>
> And in what format is the date currently stored? -MM-DD?  MySQL
> timestamp? Unix Timestamp?
>
>
> Justin French
> 
> http://Indent.com.au
> Web Development &
> Graphic Design
> 
>



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




Re: [PHP] Date problem

2002-12-01 Thread Justin French
on 02/12/02 9:59 AM, Rosen ([EMAIL PROTECTED]) wrote:

> I want to get date from database, to increment ot decrement it with some
> days, to show the date and after thath
> if user confirm it to save it to database.

And in what format is the date currently stored? -MM-DD?  MySQL
timestamp? Unix Timestamp?


Justin French

http://Indent.com.au
Web Development & 
Graphic Design



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




Re: [PHP] Date problem

2002-12-01 Thread Rosen

I want to get date from database, to increment ot decrement it with some
days, to show the date and after thath
if user confirm it to save it to database.

Can you help me ?

Thanks,
Rosen

"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
002601c29965$7862e950$7c02a8c0@coconut">news:002601c29965$7862e950$7c02a8c0@coconut...
> What exactly do you want to do? I'm not a mind reader...
>
> ---John Holmes...
>
> > -Original Message-
> > From: Rosen [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, December 01, 2002 12:54 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Date problem
> >
> > Thanks,
> > But I need before to save date in database to do some checks with the
> > inc/dec date.
> > Cal you help me ?
> >
> > Thanks,
> > Rosen
> >
> >
> > "John W. Holmes" <[EMAIL PROTECTED]> wrote in message
> > 002301c29960$21d6a360$7c02a8c0@coconut">news:002301c29960$21d6a360$7c02a8c0@coconut...
> > > > I have one problem:
> > > > Date field in MySql database with value as "2002-31-12".
> > > > I want to increment or decrement this date and to put it again in
> > > table.
> > > > Can someone help me to increment or decrement date with some days?
> > >
> > > UPDATE yourtable SET yourcolumn = yourcolumn + INTERVAL 1 DAY WHERE
> ...
> > >
> > >
> http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
> > > #Date_and_time_functions
> > >
> > > ---John Holmes...
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



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




RE: [PHP] Date problem

2002-12-01 Thread John W. Holmes
What exactly do you want to do? I'm not a mind reader...

---John Holmes...

> -Original Message-
> From: Rosen [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 01, 2002 12:54 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Date problem
> 
> Thanks,
> But I need before to save date in database to do some checks with the
> inc/dec date.
> Cal you help me ?
> 
> Thanks,
> Rosen
> 
> 
> "John W. Holmes" <[EMAIL PROTECTED]> wrote in message
> 002301c29960$21d6a360$7c02a8c0@coconut">news:002301c29960$21d6a360$7c02a8c0@coconut...
> > > I have one problem:
> > > Date field in MySql database with value as "2002-31-12".
> > > I want to increment or decrement this date and to put it again in
> > table.
> > > Can someone help me to increment or decrement date with some days?
> >
> > UPDATE yourtable SET yourcolumn = yourcolumn + INTERVAL 1 DAY WHERE
...
> >
> >
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
> > #Date_and_time_functions
> >
> > ---John Holmes...
> >
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




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




Re: [PHP] Date problem

2002-12-01 Thread Rosen
Thanks,
But I need before to save date in database to do some checks with the
inc/dec date.
Cal you help me ?

Thanks,
Rosen


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
002301c29960$21d6a360$7c02a8c0@coconut">news:002301c29960$21d6a360$7c02a8c0@coconut...
> > I have one problem:
> > Date field in MySql database with value as "2002-31-12".
> > I want to increment or decrement this date and to put it again in
> table.
> > Can someone help me to increment or decrement date with some days?
>
> UPDATE yourtable SET yourcolumn = yourcolumn + INTERVAL 1 DAY WHERE ...
>
> http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
> #Date_and_time_functions
>
> ---John Holmes...
>
>



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




RE: [PHP] Date problem

2002-12-01 Thread John W. Holmes
> I have one problem:
> Date field in MySql database with value as "2002-31-12".
> I want to increment or decrement this date and to put it again in
table.
> Can someone help me to increment or decrement date with some days?

UPDATE yourtable SET yourcolumn = yourcolumn + INTERVAL 1 DAY WHERE ...

http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
#Date_and_time_functions

---John Holmes...



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




Re: [PHP] date problem

2002-11-09 Thread Maxim Maletsky
say it again?


-- 
Maxim Maletsky
[EMAIL PROTECTED]


On Sun, 10 Nov 2002 12:37:48 +0800 "Michael P. Carel" <[EMAIL PROTECTED]> wrote:

> to all;
> 


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




Re: [PHP] date problem

2002-08-16 Thread Jason Wong

On Friday 16 August 2002 17:24, Kae Verens wrote:
> when I place date("h:i a") in a page on my server, and view it in a
> browser, I am returned: "02:51 pm". According to the server itself,
> though (logged in through ssh), using "date", it is 3:51. gmdate("h:i
> a") returns the same 2:51 time. They are both one hour off from the
> server time.
>
> Any ideas of a solution to this?
>
> Anyone have a ready-to-use function which can add/subtract an hour or
> two to/from the date/time?

mktime()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Since a politician never believes what he says, he is surprised
when others believe him.
-- Charles DeGaulle
*/


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




RE: [PHP] date problem

2002-06-06 Thread John Holmes

> >> SELECT COUNT(*) AS c
> >> FROM users_table
> >> WHERE UNIX_TIMESTAMP( user_regdate ) > '1022882400'
> >
> > The only way you can do it with a char column is to select the
entire
> > database, load it into a PHP array, using strtotime() to (hopefully)
> > convert "May 29, 2002", etc, into a unix timestamp, and then sort by
> > that timestamp.
> >
> 
> Alternatively you could use the query you are now (if its returning
the
> correct subset of rows from the table). Replace COUNT(*) AS c with
your
> primary key field (eg: id), and then use mysql_count_row() [rtfm for
more
> details] rather than pulling the rows. From here it looks like your
> fastest option, but your not providing enough information.

The query shouldn't be returning anything, b/c a unix_timestamp of a
char type column is going to be zero. So zero will never be >
1022882400. 

Also, there is no MySQL_count_row(), function. Do you mean
MySQL_num_rows()? You should use COUNT(*) in your query instead of
MySQL_num_rows(), if the count is all your after. 

---John Holmes...


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




RE: [PHP] date problem

2002-06-06 Thread Dan Hardiker

>> SELECT COUNT(*) AS c
>> FROM users_table
>> WHERE UNIX_TIMESTAMP( user_regdate ) > '1022882400'
>
> The only way you can do it with a char column is to select the entire
> database, load it into a PHP array, using strtotime() to (hopefully)
> convert "May 29, 2002", etc, into a unix timestamp, and then sort by
> that timestamp.
>

Alternatively you could use the query you are now (if its returning the
correct subset of rows from the table). Replace COUNT(*) AS c with your
primary key field (eg: id), and then use mysql_count_row() [rtfm for more
details] rather than pulling the rows. From here it looks like your
fastest option, but your not providing enough information.

-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software & Systems Engineer
First Creative Ltd



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




RE: [PHP] date problem

2002-06-06 Thread John Holmes

So what did you get? Did it work? (No. I doubt it...) Don't just post a
"question" like "Here's what I'm doing...fix it"

Anyway, your really wasting your time by not using a date or timestamp
column. If you don't understand why or realize how easy it is to change
it, you've got a lot of learning to do.

The only way you can do it with a char column is to select the entire
database, load it into a PHP array, using strtotime() to (hopefully)
convert "May 29, 2002", etc, into a unix timestamp, and then sort by
that timestamp. 

You just make things more difficult with a char column. I hope you don't
have any more queries based on time or date...

---John Holmes...

> -Original Message-
> From: andy [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 2:02 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: [PHP] date problem
> 
> Hi there,
> 
> I would like to count the users out of a mysql db who registered after
a
> certain date.
> 
> The column I have in the db is a char and I do not want to change this
> anymore.
> This is how a typical entry looks like: May 29, 2002
> 
> This is how I tryed it:
> 
> // while '10...' is unix timestamp june 1, 02
> SELECT COUNT(*) AS c
> FROM users_table
> WHERE UNIX_TIMESTAMP( user_regdate ) > '1022882400'
> 
> Thanx for any help on that,
> 
> andy
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



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




Re: [PHP] date problem

2002-06-05 Thread Miguel Cruz

On Thu, 6 Jun 2002, andy wrote:
> I would like to count the users out of a mysql db who registered after a
> certain date.
> 
> The column I have in the db is a char and I do not want to change this
> anymore.
> This is how a typical entry looks like: May 29, 2002
> 
> This is how I tryed it:
> 
> // while '10...' is unix timestamp june 1, 02
> SELECT COUNT(*) AS c
> FROM users_table
> WHERE UNIX_TIMESTAMP( user_regdate ) > '1022882400'

You can only call UNIX_TIMESTAMP on a DATE or DATETIME field, not on just
any generic CHAR/VARCHAR/TEXT/whatever. "May 29, 2002" isn't a MySQL
timestamp, so I'm guessing you have a textual field type.

The lesson of all this is: Convert dates to either unix or database-native 
date format before storing them in the database. Things like "May 29, 
2002" are useless in a database.

At this point I'd recommend running a quick script to strtotime() all your
dates and then re-write them to a new field that's in a proper format.

miguel


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




Re: [PHP] date problem

2002-04-28 Thread David Freeman

On 28 Apr 2002 at 14:48, Nick Wilson wrote:

> I have a field in MySQL db like this: date TIMESTAMP, 
> and it looks pretty regular like this: 20020428011911

If you've got the data in your database then do the date/time 
conversions as part of your sql query - it's more efficient.

Something like this would work:

$qid = db_query("SELECT DATE_FORMAT(TimeStamp, '%e %b %y') AS 
DispDate FROM sometable");

That will extract your timestamp as DD MMM  from memory - have a 
look at the MySQL manual under the chapter on selects and date/time 
formatting and you'll get the complete list of '%x' options you can 
use.

CYA, Dave


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




Re: [PHP] date problem

2002-04-28 Thread Jason Wong

On Sunday 28 April 2002 21:10, Nick Wilson wrote:
> * and then Richard Emery declared
>
> > Third, let Mysql do the conversion for you.  For instance if you
> > timestamp field is named "mydate":
> >   SELECT DATE_FORMAT(mydate,"%e %b %Y") AS thedate FROM mytable
>
> Nice one, cheers Richard.
> I didn't know about that mysql function...

Can we say, RTFM :)

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Everything is possible.  Pass the word.
-- Rita Mae Brown, "Six of One"
*/

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




Re: [PHP] date problem

2002-04-28 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* and then Richard Emery declared
> Third, let Mysql do the conversion for you.  For instance if you timestamp
> field is named "mydate":
>   SELECT DATE_FORMAT(mydate,"%e %b %Y") AS thedate FROM mytable

Nice one, cheers Richard.
I didn't know about that mysql function...
- -- 
Nick Wilson //  www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8y/S9HpvrrTa6L5oRAs9cAJ4jcd8dukhfdaJIla/irYNvnX2ZRwCgoIhU
WjS6nkU1UM44crfOGWlBxRA=
=RYIM
-END PGP SIGNATURE-

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




Re: [PHP] date problem

2002-04-28 Thread Richard Emery

First, the timestamp that is retrieved from mysql is NOT the same as is
required for PHP.

Second, do you REALLY wan the Day of the Week (Mon, Tue, Wed) or the date of
the month (1,2,3,4,5,6,...)?

Third, let Mysql do the conversion for you.  For instance if you timestamp
field is named "mydate":
  SELECT DATE_FORMAT(mydate,"%e %b %Y") AS thedate FROM mytable

- Original Message -
From: Nick Wilson <[EMAIL PROTECTED]>
To: php-general <[EMAIL PROTECTED]>
Sent: Sunday, April 28, 2002 7:48 AM
Subject: [PHP] date problem


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi all
I have a field in MySQL db like this: date TIMESTAMP,
and it looks pretty regular like this: 20020428011911

when I come to use php date("D M Y", $myTimeStamp) though I get

TUE JAN 2038!

I see something in the manual re this date but I'm afraid I still can't
work it out so some advice/help would be greatly appreciated :-)

- --
Nick Wilson //  www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD4DBQE8y++SHpvrrTa6L5oRAh3xAJ9lfFdB1VW3KUHCWxnnksN+Uw950QCYpfg6
OCdApC0Nh/8hi8MYQY3OTQ==
=FnlM
-END PGP SIGNATURE-

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



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




RE: [PHP] date problem

2002-02-18 Thread Niklas Lampén

date() is your answer, use it in the piece of code generating the query.
$DateTime = date("Y-m-d H:i:s); // "2002-02-18 16:10:43"


Niklas


-Original Message-
From: eoghan [mailto:[EMAIL PROTECTED]] 
Sent: 18. helmikuuta 2002 16:14
To: [EMAIL PROTECTED]
Subject: [PHP] date problem


hello

i am running into some trouble with a very basic problem.
i want to insert the current date/time into my db. i have 
the field set up as a datetime field. when i submit info,
i just get a blank date, i mean it all zeros, like
-00-00 00.00:00:00. how do i insert the current datetime into my db?
i tried using a hidden field with a foramtted gmt date value, but its
not working... any help

thanks - eoghan

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


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




Re: [PHP] date problem: some months have 5 weeks... how I discoverwhichones?

2001-01-18 Thread jeremy brand

> For a newspaper, a week start on sunday and ends in a saturday.
> 
> Media planners divide ads in newspapers by monhs and than by weeks,
> respectively.

Well, this _seems_ contradictory to your original "definition", but I
got it.

> so let's say:
> 
> january 2001 started in a monday
> 
> Su Mo Tu We Th Fr Sa
> 123   4   5   6  - 1st week
> 7   89  10 11 12 13  - 2nd week
> 14  15  16  17 18 19 20  - 3rd week
> 21  22  23  24 25 26 27  - 4th week
>  28  29  30  31 - 5th week

Well, get the timestamp of the first of the month:
$ts = mktime(0,0,0,1,1,2001);

then add 7 days worth of secnds to it until the month is no longer
January:

while ((int)date('m',$ts) == 1)
{
  //do stuff for this week

  $ts += (60*60*24*7);
}


> So january is a month that has 5 weeks for a newspaper, because if I would
> put an ad on a tuesday, january has 5 tuesdays.. got it?
> 
> How do I do to calculate that?

I hope this help.  It should give you the general idea.  I don't
have time to write your whole application.  ;-)  Hopefully I gave you
enough to get you going in the right direction.  

Ultimately you are going to need to cutomize this for what you exactly
want to do.

Jeremy

Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: [EMAIL PROTECTED]
http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"LINUX is obsolete"  -- Andy Tanenbaum, January 29th, 1992
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   http://www.JEEP-FOR-SALE.com/ -- I need a buyer
  Get your own Free, Private email at http://www.smackdown.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date problem: some months have 5 weeks... how I discoverwhich ones?

2001-01-18 Thread Romulo Roberto Pereira

For a newspaper, a week start on sunday and ends in a saturday.

Media planners divide ads in newspapers by monhs and than by weeks,
respectively.

so let's say:

january 2001 started in a monday

Su Mo Tu We Th Fr Sa
123   4   5   6  - 1st week
7   89  10 11 12 13  - 2nd week
14  15  16  17 18 19 20  - 3rd week
21  22  23  24 25 26 27  - 4th week
 28  29  30  31 - 5th week

So january is a month that has 5 weeks for a newspaper, because if I would
put an ad on a tuesday, january has 5 tuesdays.. got it?

How do I do to calculate that?

Damn question!

Rom



- Original Message -
From: jeremy brand <[EMAIL PROTECTED]>
To: Romulo Roberto Pereira <[EMAIL PROTECTED]>
Cc: php-general <[EMAIL PROTECTED]>
Sent: Thursday, January 18, 2001 7:14 PM
Subject: Re: [PHP] date problem: some months have 5 weeks... how I
discoverwhich ones?


All months have more than 4 weeks except February (but only when it is
not a leap year).

I'm probably not understanding what exactly you are trying to do.

By your definition then, wouldn't this month only have 3 weeks?
January 2001
Su Mo Tu We Th Fr Sa
1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

Yet there are 10 unaccounted days which is 1 and 3/7 more weeks.

Jeremy

Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: [EMAIL PROTECTED]
http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"LINUX is obsolete"  -- Andy Tanenbaum, January 29th, 1992
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   http://www.JEEP-FOR-SALE.com/ -- I need a buyer
  Get your own Free, Private email at http://www.smackdown.com/

On Thu, 18 Jan 2001, Romulo Roberto Pereira wrote:

> Date: Thu, 18 Jan 2001 19:07:31 -0500
> From: Romulo Roberto Pereira <[EMAIL PROTECTED]>
> To: php-general <[EMAIL PROTECTED]>
> Subject: [PHP] date problem: some months have 5 weeks... how I discover
which
ones?
>
> Hey!
>
> A little bit of definition:
>
> - a week start on sunday and ends on saturday;
>
> - a year has 365/7 ~= 52 weeks;
>
> How do I discover what months have 5 weeks and what have 4?
>
> Rom
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date problem: some months have 5 weeks... how I discoverwhich ones?

2001-01-18 Thread jeremy brand

All months have more than 4 weeks except February (but only when it is
not a leap year).

I'm probably not understanding what exactly you are trying to do.

By your definition then, wouldn't this month only have 3 weeks?  
January 2001
Su Mo Tu We Th Fr Sa 
1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

Yet there are 10 unaccounted days which is 1 and 3/7 more weeks.

Jeremy

Jeremy Brand :: Sr. Software Engineer :: 408-245-9058 :: [EMAIL PROTECTED]
http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"LINUX is obsolete"  -- Andy Tanenbaum, January 29th, 1992
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   http://www.JEEP-FOR-SALE.com/ -- I need a buyer
  Get your own Free, Private email at http://www.smackdown.com/

On Thu, 18 Jan 2001, Romulo Roberto Pereira wrote:

> Date: Thu, 18 Jan 2001 19:07:31 -0500
> From: Romulo Roberto Pereira <[EMAIL PROTECTED]>
> To: php-general <[EMAIL PROTECTED]>
> Subject: [PHP] date problem: some months have 5 weeks... how I discover which
ones?
> 
> Hey!
> 
> A little bit of definition:
> 
> - a week start on sunday and ends on saturday;
> 
> - a year has 365/7 ~= 52 weeks;
> 
> How do I discover what months have 5 weeks and what have 4?
> 
> Rom
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date problem: some months have 5 weeks... how I discover which ones?

2001-01-18 Thread Josh G

can't think of exactly the math, but get the weekdayday of the 1st,
divide how many days in the month/7, and it should be easy enuff.

use a combination of date() and mktime() to get the first day of the
month methinks.

Gfunk -  http://www.gfunk007.com/

I sense much beer in you. Beer leads to intoxication, intoxication to
hangovers, and hangovers to... suffering.


- Original Message -
From: "Romulo Roberto Pereira" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Friday, January 19, 2001 11:07 AM
Subject: [PHP] date problem: some months have 5 weeks... how I discover
which ones?


Hey!

A little bit of definition:

- a week start on sunday and ends on saturday;

- a year has 365/7 ~= 52 weeks;

How do I discover what months have 5 weeks and what have 4?

Rom



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]