Re: [PHP] Mktime formatting problems

2006-05-11 Thread Ryan A
Hey Rich,

> > 1) read the files from a directory, discard the
> files
> > with a  .php extention and the directories (eg: .
> and
> > .. )
> >
> > 2) put the files into an array ($the_files[])
> >
> > 3) put it into a while loop and display the files
> like
> > so:
> 
> //Only do files over 2 hours old:
> if ((time() - filectime($dir...[$i])) > 60*60*2){
> 
> > echo $the_files[$i] . date("F d Y H:i:s.",
> > filectime($directory_with_files.$the_files[$i]));
> 
> }
> 
> You may need a '/' in there...
> 


Thanks for replying, solved it,  I am using Stuts
suggestion/code (all credit to him) like so:

$threshold = strtotime('-1 hours');
(for or while loop comes here){

if (file_exists($directory_with_files.$the_files[$i]))

{

if (filectime($directory_with_files.$the_files[$i])
< $threshold)
{
   echo "".$the_files[$i] ." - ". date("F d Y
H:i:s.",
filectime($directory_with_files.$the_files[$i]))."
".$file_time_details[0]."";
}
}

}


And it works perfectly if you see anything wrong
with the above or would like to suggest a change, feel
free to tell me, am feeling "brain low" so it is
possible i missed something.

For now I am doing a simple echo, will be changing
that to some manipulation of the files as the project
goes along. One step at a time...

Cheers!
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



RE: [PHP] Mktime formatting problems

2006-05-11 Thread Jef Sullivan
Here is what I have used for mktime..

$unix_date_33 = mktime(0,0,0,date("m"),date("d")-33,date("Y"));

I am getting the current month, day, and year from the system.
I am subtracting 33 days from the current day.
The result is compared to a date value from the database.



Jef
-Original Message-
From: Ryan A [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 11, 2006 2:38 PM
To: php php
Subject: [PHP] Mktime formatting problems

Hey,

So far this is what I have done:
-
1) read the files from a directory, discard the files
with a  .php extention and the directories (eg: . and
.. )

2) put the files into an array ($the_files[])

3) put it into a while loop and display the files like
so:

echo $the_files[$i] . date("F d Y H:i:s.",
filectime($directory_with_files.$the_files[$i]));
-


The next step is, I want to only echo the files that
are over x minutes (or x hours) old, ignore anything
below, I am using mktime() along with date() to format
it accordingly...but am unable to do so.



Can someone kindly give me a quick example on how to
do this? sitting too long on the comp, I think i'm
losing it :-(

If you want the php file that i have written please
tell me and will send it to you offlist.

Thanks!
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
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] Mktime formatting problems

2006-05-11 Thread Richard Lynch
On Thu, May 11, 2006 3:37 pm, Ryan A wrote:
> So far this is what I have done:
> -
> 1) read the files from a directory, discard the files
> with a  .php extention and the directories (eg: . and
> .. )
>
> 2) put the files into an array ($the_files[])
>
> 3) put it into a while loop and display the files like
> so:

//Only do files over 2 hours old:
if ((time() - filectime($dir...[$i])) > 60*60*2){

> echo $the_files[$i] . date("F d Y H:i:s.",
> filectime($directory_with_files.$the_files[$i]));

}

You may need a '/' in there...

> -
>
>
> The next step is, I want to only echo the files that
> are over x minutes (or x hours) old, ignore anything
> below, I am using mktime() along with date() to format
> it accordingly...but am unable to do so.
>
>
>
> Can someone kindly give me a quick example on how to
> do this? sitting too long on the comp, I think i'm
> losing it :-(
>
> If you want the php file that i have written please
> tell me and will send it to you offlist.
>
> Thanks!
> Ryan
>
> --
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
> -
> Fight back spam! Download the Blue Frog.
> http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D
>
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
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] Mktime formatting problems

2006-05-11 Thread Ryan A
Hey,

First, thank you Eric and Stut, your answers and this
article that I found on the web
http://www.phpbuilder.com/columns/akent2610.php3?print_mode=1

put my mind back on the right tracksometimes its
so damn silly how things you use for ages suddenly get
"muddled" up in the head.

Thanks again,
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] Mktime formatting problems

2006-05-11 Thread Eric Butera

On 5/11/06, Ryan A <[EMAIL PROTECTED]> wrote:

Hey,

So far this is what I have done:
-
1) read the files from a directory, discard the files
with a  .php extention and the directories (eg: . and
.. )

2) put the files into an array ($the_files[])

3) put it into a while loop and display the files like
so:

echo $the_files[$i] . date("F d Y H:i:s.",
filectime($directory_with_files.$the_files[$i]));
-


The next step is, I want to only echo the files that
are over x minutes (or x hours) old, ignore anything
below, I am using mktime() along with date() to format
it accordingly...but am unable to do so.



Can someone kindly give me a quick example on how to
do this? sitting too long on the comp, I think i'm
losing it :-(

If you want the php file that i have written please
tell me and will send it to you offlist.

Thanks!
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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




One thing you could do:

$old_time = time() - 60*15;

echo "old time: ". $old_time;

foreach (glob("*.php") as $filename) {
   echo "file ({$filename}) time ". filectime($filename);
  ///echo "$filename size " . filesize($filename) . "\n";

  if (filectime($filename) <= $old_time) {
   echo "--showing: ". $filename;
  }
}

Filectime is just a unix timestamp as is time().  So just subtract the
number of seconds you want to show and compare on that.

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



Re: [PHP] Mktime formatting problems

2006-05-11 Thread Stut

Ryan A wrote:

echo $the_files[$i] . date("F d Y H:i:s.",
filectime($directory_with_files.$the_files[$i]));

The next step is, I want to only echo the files that
are over x minutes (or x hours) old, ignore anything
below, I am using mktime() along with date() to format
it accordingly...but am unable to do so.


$threshold = strtotime('-10 minutes');
if (filectime($directory_with_files.$the_files[$i]) < $threshold)
echo that snippet above


Something like that should do it, except with the looping after the 
threshold is set.


-Stut

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



RE: [PHP] mktime() vs date()

2006-04-18 Thread Jay Blanchard
[snip]
hi, is mktime() actually faster than date() or any other date functions?
[/snip]

This sounds like the perfect opportunity for you to write a test and
return the results.

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



Re: [PHP] mktime month

2006-03-10 Thread Austin Denyer
Mark Steudel wrote:
> Im a little confused on the number I should use for the month:
>  
> Take the following:
>  
> echo date('Ymd', mktime(0, 0, 0, 3, 0, date("Y")) );
>  
> I expected it to output: 20060331
>  
> But instead it outputs 20060228.

Correct.

You are asking it for the zeroth day of March, which is the last day of
February.

Regards,
Ozz.


signature.asc
Description: OpenPGP digital signature


RE: [PHP] mktime

2005-09-13 Thread Ford, Mike
On 13 September 2005 00:08, Dan Brow wrote:

> A little confused with mktime, I'm trying to get how many
> days are in a
> year.
> 
> $year = "2006";
> $epoch = mktime(0, 0, 0, 1, 0, $year); // I have to have 1

You're asking for the 0th day of the first month here, which is (guess what!) 
the last day of *last* year.  If you want to get the last day of *this* year, 
you need to ask for the 0th day of *next* year; or, more trickily, the 0th day 
of the 13th month of *this* year! (Note: I haven't tested this, but logically 
it should work... ;)  So, either of these should get what you want:

  $epoch = mktime(0, 0, 0, 1, 0, $year+1); 
  $epoch = mktime(0, 0, 0, 13, 0, $year); 

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 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] mktime

2005-09-12 Thread Dan Brow
snip
> 
> I'd shorten it up even more:
> 
>  $daysinyear = 365 + date("L", strtotime("jan 1 " . $year));
> ?>

Thanks works perfect.

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



Re: [PHP] mktime

2005-09-12 Thread Dan Brow
On Tue, 2005-09-13 at 11:13 +1200, Jasper Bryant-Greene wrote:
> Dan Brow wrote:
> > A little confused with mktime, I'm trying to get how many days are in a
> > year.
> 
> How about doing it differently. I'd tackle this problem like this:
> 
>  $year = '2005';
> $time = strtotime("1 January $year");
> $isLeapYear = date('L', $time);
> 
> if($isLeapYear == '1') {
>   $days = 366;
> } else {
>   $days = 365;
> }
> ?>



Thanks.

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



Re: [PHP] mktime

2005-09-12 Thread Brian P. O'Donnell

"Jasper Bryant-Greene" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Dan Brow wrote:
> > A little confused with mktime, I'm trying to get how many days are in a
> > year.
>
> How about doing it differently. I'd tackle this problem like this:
>
>  $year = '2005';
> $time = strtotime("1 January $year");
> $isLeapYear = date('L', $time);
>
> if($isLeapYear == '1') {
> $days = 366;
> } else {
> $days = 365;
> }
> ?>

I'd shorten it up even more:



Brian

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



Re: [PHP] mktime

2005-09-12 Thread Jasper Bryant-Greene

Dan Brow wrote:

A little confused with mktime, I'm trying to get how many days are in a
year.


How about doing it differently. I'd tackle this problem like this:



--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

If you find my advice useful, please consider donating to a poor
student! You can choose whatever amount you think my advice was
worth to you. http://tinyurl.com/7oa5s

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



Re: [PHP] Mktime strange

2005-08-31 Thread Robin Vickery
On 8/31/05, Hal 9001 Consulting <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I've got a problem with mktime. It's a very strange behaviour, I don't know
> if is a bug:
> 
> 
> echo date ("M-d-Y", mktime (0,0,0,07,07,2005)); -> Jul-07-2005 (right)
> echo date ("M-d-Y", mktime (0,0,0,08,07,2005)); -> Dec-07-2004 (?)
> 
> Can anyone help me to solve this question? Is it a bug?

Numbers with leading zeros are octal. 08 is not a valid octal number,
and is interpreted as 0.

The solution is to not use leading zeros...

echo date ("M-d-Y", mktime (0,0,0,8,7,2005)); -> Aug-07-2005

-robin

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



Re: [PHP] mktime error

2004-04-05 Thread Red Wingate
You could do this like this ( as it is faster ):

function CreateDate($day, $month, $year) {
return $year.$month.$day.'00';
}

CreateDate(04,04,2004) -> 2004040400

But make sure you add the leading zero to $month and $day ( can
be easily done (number_format for example) )

 -- red

Am Montag, 5. April 2004 13:20 schrieb Andy B:
> if you need to turn the result of mktime() into a valid mysql timestamp
> format then put these 2 lines in your code when needed:
>  //create valid mysql timestamp(14 digit)
> //change to fit your liking
> //sorry turned into a function...
> function CreateDate($day, $month, $year);
> //make sure no arguments were left out
> if!empty($day) && !empty($month) && !empty($year)){
> $time=mktime(0,0,0,'$month','$year');
> //convert to a formated stamp
> $time=date("YmdHis", $time);
> return $time;}
> else{return false;}

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



Re: [PHP] mktime error

2004-04-05 Thread Hernan Marino
Guys, second thought.
mktime builds a unix time stamp (since the unix epoch, Jan 1, 1970 [I
guess]), the difference are maybe due to time zones, because its the
number of seconds since Jan,1 1970.



On Mon, 5 Apr 2004 06:29:12 -0400, Andy B wrote:
"On my personal machine the return value is:

1081026000"
interesting... i got 1081054800 from mine with the code:


 even on cli it gives the same thing

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

2004-04-05 Thread Hernan Marino
I got 1081047600 for
$time=mktime(0,0,0,4,4,2004);
echo $time;

(RH9, PHP 4.3.4)


On Mon, 5 Apr 2004 11:34:11 +0100, Nunners wrote:
I got 1081033200

Two thoughts:
1 - is $time a global variable predefined as the current time? Don't
think
it is?!?!?!

2 - Could it be to do with local time settings i.e. comparing american
dates
with UK dates (1/Aug/04 and 8/1/04)?

Nunners



> -Original Message-
> From: Andy B [mailto:[EMAIL PROTECTED]
> Sent: 05 April 2004 11:29
> To: [EMAIL PROTECTED]
> Subject: [PHP] mktime error
>
> "On my personal machine the return value is:
>
> 1081026000"
> interesting... i got 1081054800 from mine with the code:
>  $time=mktime(0,0,0,4,4,2004);
> echo $time;
> ?>
>
>  even on cli it gives the same thing
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

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



Re: [PHP] mktime error

2004-04-05 Thread Red Wingate
Woops little mistake there, first of all it's 'gmmktime()' secondly the source
should look something like:

$var = mktime ( 0,0,1,4,4,2004 ) - 1;

You can find a nice article on this topic here:
http://www.phpbuilder.com/columns/ehresman20030911.php3?page=1

  -- red

[...]
> Your Server will most likely run in a different timezone. If both of you
> would use gmktime() the result will be the same.
>
> As for the negative result: Had the same problem some time ago - seams
> to me as if PHP doesn't like those 0,0,0 ( try 0,0,1 instead ) - You can
> adjust the result by reducing the result by 1
>
> $var = mktime ( 0,0,0,4,4,2004 ) - 1 ;
>
>   -- red
[...]

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



Re: [PHP] mktime error

2004-04-05 Thread Red Wingate
Your Server will most likely run in a different timezone. If both of you
would use gmktime() the result will be the same.

As for the negative result: Had the same problem some time ago - seams
to me as if PHP doesn't like those 0,0,0 ( try 0,0,1 instead ) - You can
adjust the result by reducing the result by 1

$var = mktime ( 0,0,0,4,4,2004 ) - 1 ;

  -- red

Am Montag, 5. April 2004 12:29 schrieb Andy B:
> "On my personal machine the return value is:
>
> 1081026000"
> interesting... i got 1081054800 from mine with the code:
>  $time=mktime(0,0,0,4,4,2004);
> echo $time;
> ?>
>
>  even on cli it gives the same thing

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



RE: [PHP] mktime error

2004-04-05 Thread Nunners
I got 1081033200

Two thoughts:
1 - is $time a global variable predefined as the current time? Don't think
it is?!?!?!

2 - Could it be to do with local time settings i.e. comparing american dates
with UK dates (1/Aug/04 and 8/1/04)?

Nunners



> -Original Message-
> From: Andy B [mailto:[EMAIL PROTECTED]
> Sent: 05 April 2004 11:29
> To: [EMAIL PROTECTED]
> Subject: [PHP] mktime error
> 
> "On my personal machine the return value is:
> 
> 1081026000"
> interesting... i got 1081054800 from mine with the code:
>  $time=mktime(0,0,0,4,4,2004);
> echo $time;
> ?>
> 
>  even on cli it gives the same thing
> 
> --
> 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] mktime trouble

2003-10-20 Thread Chris Shiflett
--- Peter Torraca <[EMAIL PROTECTED]> wrote:
> print date ("m/d/y h:m:s A", mktime(16, 30, 0, 10, 10, 2003));
> 
> gives the output: 10/10/03 04:10:00 AM
> 
> Where did the 4:10 come from?  It should be 4:*30*.

10 is the month, which is what the m means. Use i for minute:

http://www.php.net/date

Hope that helps.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

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



Re: [PHP] mktime with Feb or Jan ..

2003-02-03 Thread 1LT John W. Holmes
> I parse the apache logfile and get a date format like this
> [03/Feb/2003:09:22:50 +0100]
> OK i split it with preg_match and the result is
>
> Array
> (
> [0] => 03
> [1] => Feb
> [2] => 2003
> [3] => 09
> [4] => 22
> [5] => 50
> )
>
> Now I'd like to convert it in a timestamp
> with mktime but the problem is Feb ($t[1])
>
> $lasttime = mktime($t[3], $t[4], $t[5], $t[1], $t[0], $t[2]);
>
> Is it possible to convert Feb in 02,

If strtotime() doesn't work on the whole thing, then the easy way to get
'Feb' to 2 is to just create an array.

$month = array('Jan' => 1, 'Feb' => 2, 'Mar' => 3 ... etc.

Then, just use:

$lasttime = mktime($t[3], $t[4], $t[5], $month[$t[1]], $t[0], $t[2]);

---John Holmes...


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




Re: [PHP] mktime with Feb or Jan ..

2003-02-03 Thread Maxim Maletsky
readon about strtotime() function
www.php.net/strtotime

you might not even need to preg_match() it  


--
Maxim Maletsky
[EMAIL PROTECTED]



Torsten Rosenberger <[EMAIL PROTECTED]> wrote... :

> Hello
> 
>   I parse the apache logfile and get a date format like this
> [03/Feb/2003:09:22:50 +0100] 
> OK i split it with preg_match and the result is 
> 
> Array
> (
> [0] => 03
> [1] => Feb
> [2] => 2003
> [3] => 09
> [4] => 22
> [5] => 50
> )
> 
> Now I'd like to convert it in a timestamp 
> with mktime but the problem is Feb ($t[1])
> 
> $lasttime = mktime($t[3], $t[4], $t[5], $t[1], $t[0], $t[2]);
> 
> Is it possible to convert Feb in 02,
> 
> BR/Torsten
> 
> 
> 
> -- 
> 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] mktime() and the format of the day number entry

2003-01-03 Thread Ford, Mike [LSS]
> -Original Message-
> From: Johnson, Kirk [mailto:[EMAIL PROTECTED]]
> Sent: 02 January 2003 23:29
> 
> The month behaves the same: both '08' and '09' are treated as zero by
> mktime().

A leading 0 on a number denotes it as octal.  08 and 09 are not valid octal
numbers.  PHP is interpreting as much of the number as it can (i.e. the
leading 0) and ignoring the invalid part.  This gives you your zero results.

Cheers!

Mike

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

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




RE: [PHP] mktime() and the format of the day number entry

2003-01-02 Thread Michael J. Pawlowsky

Just to add to that... what it is doing is reading it as a 0.

0,0,0,09,30,1998 => 883458000
Tue, 30 Dec 1997 00:00:00 -0500

0,0,0,0,30,1998 => 883458000
Tue, 30 Dec 1997 00:00:00 -0500


Did you see this in the manual?

"The last day of any given month can be expressed as the 0 day of the next month, not 
the -1 day. "

I wonder if 0 has some significance in the month also?




Ok back to work  :-)









*** REPLY SEPARATOR  ***

On 02/01/2003 at 7:17 PM Michael J. Pawlowsky wrote:

>Well you are right.. I also get the same results...
>I guess you found a bug...   did you look in the bug reports to see if it
>already exists?
>
>
>




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




RE: [PHP] mktime() and the format of the day number entry

2003-01-02 Thread Michael J. Pawlowsky
Well you are right.. I also get the same results...
I guess you found a bug...   did you look in the bug reports to see if it already 
exists?




Results


Thu, 2 Jan 2003 19:15:35 -0500
0,0,0,10,0,1998 => 907128000
0,0,0,10,00,1998 => 907128000
0,0,0,10,1,1998 => 907214400
0,0,0,10,01,1998 => 907214400
0,0,0,10,2,1998 => 907300800
0,0,0,10,02,1998 => 907300800
0,0,0,10,3,1998 => 907387200
0,0,0,10,03,1998 => 907387200
0,0,0,10,4,1998 => 907473600
0,0,0,10,04,1998 => 907473600
0,0,0,10,5,1998 => 90756
0,0,0,10,05,1998 => 90756
0,0,0,10,6,1998 => 907646400
0,0,0,10,06,1998 => 907646400
0,0,0,10,7,1998 => 907732800
0,0,0,10,07,1998 => 907732800
0,0,0,10,8,1998 => 907819200
Thu, 8 Oct 1998 00:00:00 -0400
0,0,0,10,08,1998 => 907128000
Wed, 30 Sep 1998 00:00:00 -0400

0,0,0,10,9,1998 => 907905600
Fri, 9 Oct 1998 00:00:00 -0400

0,0,0,10,09,1998 => 907128000
Wed, 30 Sep 1998 00:00:00 -0400

0,0,0,9,30,1998 => 907128000
Wed, 30 Sep 1998 00:00:00 -0400

0,0,0,09,30,1998 => 883458000
Tue, 30 Dec 1997 00:00:00 -0500



-  Code --


";
$tmp = mktime(0,0,0,10,0,1998);
echo "0,0,0,10,0,1998 => $tmp";
$tmp = mktime(0,0,0,10,00,1998);
echo "0,0,0,10,00,1998 => $tmp";
$tmp = mktime(0,0,0,10,1,1998);
echo "0,0,0,10,1,1998 => $tmp";
$tmp = mktime(0,0,0,10,01,1998);
echo "0,0,0,10,01,1998 => $tmp";
$tmp = mktime(0,0,0,10,2,1998);
echo "0,0,0,10,2,1998 => $tmp";
$tmp = mktime(0,0,0,10,02,1998);
echo "0,0,0,10,02,1998 => $tmp";
$tmp = mktime(0,0,0,10,3,1998);
echo "0,0,0,10,3,1998 => $tmp";
$tmp = mktime(0,0,0,10,03,1998);
echo "0,0,0,10,03,1998 => $tmp";
$tmp = mktime(0,0,0,10,4,1998);
echo "0,0,0,10,4,1998 => $tmp";
$tmp = mktime(0,0,0,10,04,1998);
echo "0,0,0,10,04,1998 => $tmp";
$tmp = mktime(0,0,0,10,5,1998);
echo "0,0,0,10,5,1998 => $tmp";
$tmp = mktime(0,0,0,10,05,1998);
echo "0,0,0,10,05,1998 => $tmp";
$tmp = mktime(0,0,0,10,6,1998);
echo "0,0,0,10,6,1998 => $tmp";
$tmp = mktime(0,0,0,10,06,1998);
echo "0,0,0,10,06,1998 => $tmp";
$tmp = mktime(0,0,0,10,7,1998);
echo "0,0,0,10,7,1998 => $tmp";
$tmp = mktime(0,0,0,10,07,1998);
echo "0,0,0,10,07,1998 => $tmp";
$tmp = mktime(0,0,0,10,8,1998);
echo "0,0,0,10,8,1998 => $tmp";
echo date("r", $tmp) . "";
$tmp = mktime(0,0,0,10,08,1998);
echo "0,0,0,10,08,1998 => $tmp";
echo date("r", $tmp) . "";
$tmp = mktime(0,0,0,10,9,1998);
echo "0,0,0,10,9,1998 => $tmp";
echo date("r", $tmp) . "";
$tmp = mktime(0,0,0,10,09,1998);
echo "0,0,0,10,09,1998 => $tmp";
echo date("r", $tmp) . "";

$tmp = mktime(0,0,0,9,30,1998);
echo "0,0,0,9,30,1998 => $tmp";
echo date("r", $tmp) . "";

$tmp = mktime(0,0,0,09,30,1998);
echo "0,0,0,09,30,1998 => $tmp";
echo date("r", $tmp) . "";



?>








*** REPLY SEPARATOR  ***

On 02/01/2003 at 4:29 PM Johnson, Kirk wrote:

>The month behaves the same: both '08' and '09' are treated as zero by
>mktime().
>
>Kirk
>



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




RE: [PHP] mktime() and the format of the day number entry

2003-01-02 Thread Johnson, Kirk
The month behaves the same: both '08' and '09' are treated as zero by
mktime().

Kirk

> -Original Message-
> From: Paul Roberts [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 02, 2003 4:24 PM
> To: Johnson, Kirk
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] mktime() and the format of the day number entry
> 
> 
> same here win 2K apache php4.21
> 
> output
> 
> 0,0,0,10,0,1998 => 90711
> 0,0,0,10,00,1998 => 90711
> 0,0,0,10,1,1998 => 907196400
> 0,0,0,10,01,1998 => 907196400
> 0,0,0,10,2,1998 => 907282800
> 0,0,0,10,02,1998 => 907282800
> 0,0,0,10,3,1998 => 907369200
> 0,0,0,10,03,1998 => 907369200
> 0,0,0,10,4,1998 => 907455600
> 0,0,0,10,04,1998 => 907455600
> 0,0,0,10,5,1998 => 907542000
> 0,0,0,10,05,1998 => 907542000
> 0,0,0,10,6,1998 => 907628400
> 0,0,0,10,06,1998 => 907628400
> 0,0,0,10,7,1998 => 907714800
> 0,0,0,10,07,1998 => 907714800
> 0,0,0,10,8,1998 => 907801200
> 0,0,0,10,08,1998 => 90711
> 0,0,0,10,9,1998 => 907887600
> 0,0,0,10,09,1998 => 90711
> 
> code
>  $tmp = mktime(0,0,0,10,0,1998);
> echo "0,0,0,10,0,1998 => $tmp";
> $tmp = mktime(0,0,0,10,00,1998);
> echo "0,0,0,10,00,1998 => $tmp";
> $tmp = mktime(0,0,0,10,1,1998);
> echo "0,0,0,10,1,1998 => $tmp";
> $tmp = mktime(0,0,0,10,01,1998);
> echo "0,0,0,10,01,1998 => $tmp";
> $tmp = mktime(0,0,0,10,2,1998);
> echo "0,0,0,10,2,1998 => $tmp";
> $tmp = mktime(0,0,0,10,02,1998);
> echo "0,0,0,10,02,1998 => $tmp";
> $tmp = mktime(0,0,0,10,3,1998);
> echo "0,0,0,10,3,1998 => $tmp";
> $tmp = mktime(0,0,0,10,03,1998);
> echo "0,0,0,10,03,1998 => $tmp";
> $tmp = mktime(0,0,0,10,4,1998);
> echo "0,0,0,10,4,1998 => $tmp";
> $tmp = mktime(0,0,0,10,04,1998);
> echo "0,0,0,10,04,1998 => $tmp";
> $tmp = mktime(0,0,0,10,5,1998);
> echo "0,0,0,10,5,1998 => $tmp";
> $tmp = mktime(0,0,0,10,05,1998);
> echo "0,0,0,10,05,1998 => $tmp";
> $tmp = mktime(0,0,0,10,6,1998);
> echo "0,0,0,10,6,1998 => $tmp";
> $tmp = mktime(0,0,0,10,06,1998);
> echo "0,0,0,10,06,1998 => $tmp";
> $tmp = mktime(0,0,0,10,7,1998);
> echo "0,0,0,10,7,1998 => $tmp";
> $tmp = mktime(0,0,0,10,07,1998);
> echo "0,0,0,10,07,1998 => $tmp";
> $tmp = mktime(0,0,0,10,8,1998);
> echo "0,0,0,10,8,1998 => $tmp";
> $tmp = mktime(0,0,0,10,08,1998);
> echo "0,0,0,10,08,1998 => $tmp";
> $tmp = mktime(0,0,0,10,9,1998);
> echo "0,0,0,10,9,1998 => $tmp";
> $tmp = mktime(0,0,0,10,09,1998);
> echo "0,0,0,10,09,1998 => $tmp";
> ?>
> 
> 
> - Original Message - 
> From: "Johnson, Kirk" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, January 02, 2003 8:50 PM
> Subject: [PHP] mktime() and the format of the day number entry
> 
> 
> 
> OK, I am mktime() challenged. Can someone please explain 
> these results to
> me?
> 
> I have some test dates in October of 1998. For the days numbered 1-7,
> mktime() does not care whether I have a leading zero on the 
> day or not, I
> get the same timestamp regardless, e.g., both a '7' and a 
> '07' for the day
> number give the same timestamp. However, for the days 8-9, I 
> get different
> timestamps for each if I use '8' versus '08' and '9' versus 
> '09'. In these
> latter two cases, mktime treats both '08' and '09' as '0', 
> and it gives the
> same timestamp as Oct 0 1998. What's up?
> 
> The code is below if you want to have a look.
> 
> Kirk
> 
> Kirk Johnson
> [EMAIL PROTECTED]
> 
> "0, as a number, is just as important as any other number."

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




Re: [PHP] mktime() and the format of the day number entry

2003-01-02 Thread Paul Roberts
same here win 2K apache php4.21

output

0,0,0,10,0,1998 => 90711
0,0,0,10,00,1998 => 90711
0,0,0,10,1,1998 => 907196400
0,0,0,10,01,1998 => 907196400
0,0,0,10,2,1998 => 907282800
0,0,0,10,02,1998 => 907282800
0,0,0,10,3,1998 => 907369200
0,0,0,10,03,1998 => 907369200
0,0,0,10,4,1998 => 907455600
0,0,0,10,04,1998 => 907455600
0,0,0,10,5,1998 => 907542000
0,0,0,10,05,1998 => 907542000
0,0,0,10,6,1998 => 907628400
0,0,0,10,06,1998 => 907628400
0,0,0,10,7,1998 => 907714800
0,0,0,10,07,1998 => 907714800
0,0,0,10,8,1998 => 907801200
0,0,0,10,08,1998 => 90711
0,0,0,10,9,1998 => 907887600
0,0,0,10,09,1998 => 90711

code
 $tmp";
$tmp = mktime(0,0,0,10,00,1998);
echo "0,0,0,10,00,1998 => $tmp";
$tmp = mktime(0,0,0,10,1,1998);
echo "0,0,0,10,1,1998 => $tmp";
$tmp = mktime(0,0,0,10,01,1998);
echo "0,0,0,10,01,1998 => $tmp";
$tmp = mktime(0,0,0,10,2,1998);
echo "0,0,0,10,2,1998 => $tmp";
$tmp = mktime(0,0,0,10,02,1998);
echo "0,0,0,10,02,1998 => $tmp";
$tmp = mktime(0,0,0,10,3,1998);
echo "0,0,0,10,3,1998 => $tmp";
$tmp = mktime(0,0,0,10,03,1998);
echo "0,0,0,10,03,1998 => $tmp";
$tmp = mktime(0,0,0,10,4,1998);
echo "0,0,0,10,4,1998 => $tmp";
$tmp = mktime(0,0,0,10,04,1998);
echo "0,0,0,10,04,1998 => $tmp";
$tmp = mktime(0,0,0,10,5,1998);
echo "0,0,0,10,5,1998 => $tmp";
$tmp = mktime(0,0,0,10,05,1998);
echo "0,0,0,10,05,1998 => $tmp";
$tmp = mktime(0,0,0,10,6,1998);
echo "0,0,0,10,6,1998 => $tmp";
$tmp = mktime(0,0,0,10,06,1998);
echo "0,0,0,10,06,1998 => $tmp";
$tmp = mktime(0,0,0,10,7,1998);
echo "0,0,0,10,7,1998 => $tmp";
$tmp = mktime(0,0,0,10,07,1998);
echo "0,0,0,10,07,1998 => $tmp";
$tmp = mktime(0,0,0,10,8,1998);
echo "0,0,0,10,8,1998 => $tmp";
$tmp = mktime(0,0,0,10,08,1998);
echo "0,0,0,10,08,1998 => $tmp";
$tmp = mktime(0,0,0,10,9,1998);
echo "0,0,0,10,9,1998 => $tmp";
$tmp = mktime(0,0,0,10,09,1998);
echo "0,0,0,10,09,1998 => $tmp";
?>


- Original Message - 
From: "Johnson, Kirk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 02, 2003 8:50 PM
Subject: [PHP] mktime() and the format of the day number entry



OK, I am mktime() challenged. Can someone please explain these results to
me?

I have some test dates in October of 1998. For the days numbered 1-7,
mktime() does not care whether I have a leading zero on the day or not, I
get the same timestamp regardless, e.g., both a '7' and a '07' for the day
number give the same timestamp. However, for the days 8-9, I get different
timestamps for each if I use '8' versus '08' and '9' versus '09'. In these
latter two cases, mktime treats both '08' and '09' as '0', and it gives the
same timestamp as Oct 0 1998. What's up?

The code is below if you want to have a look.

Kirk

Kirk Johnson
[EMAIL PROTECTED]

"0, as a number, is just as important as any other number."

";
$tmp = mktime(0,0,0,10,00,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,1,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,01,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,2,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,02,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,3,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,03,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,4,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,04,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,5,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,05,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,6,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,06,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,7,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,07,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,8,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,08,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,9,1998);
echo "$tmp";
$tmp = mktime(0,0,0,10,09,1998);
echo "$tmp";
?>

-- 
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] mktime() question

2002-08-02 Thread Tom Rogers

Hi,

Friday, August 2, 2002, 10:52:14 PM, you wrote:
JB> Good morning!

JB> I need to subtract months by their abbreviated month name, so shouldn't this
JB> work?

JB> print(date("M", mktime(date("M")-$i));

JB> and if I loop;

JB> Aug
JB> Jul
JB> Jun
JB> May
JB> 
Does this help...


$now = time();
$i = 36;
while($i > 0){
echo date('M-Y',$now).'';
$now = strtotime('-1 month',$now);
$i--;
}






-- 
regards,
Tom


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




RE: [PHP] mktime() question - SOLVED

2002-08-02 Thread Jay Blanchard

[snip]
I need to subtract months by their abbreviated month name, so shouldn't this
work?

print(date("M", mktime(date("M")-$i));

and if I loop;

Aug
Jul
Jun
May

[/snip]

Apparently not. But you can subtract by total hours in a given period, so
for an average I chose 30 days * 24 hours (720);

$i = 36;
$h = 720;
while($i > 0){
print(date("M", mktime(date("M")-$h)));print(date("Y"));print("");
$i--;
$h = $h + 720;
}

which results in

Jul2002
Jun2002
May2002
Apr2002
Mar2002
Feb2002
Jan2002
Dec2002
Nov2002
Oct2002
Sep2002
Aug2002
Jul2002
Jun2002
May2002

So now all I have to do is sove the year rollover, which I think I can do
the same way. It'd be so much easier if mktime worked as the documentation
said, but after many iterations of different things this is what I was able
to come up with.

Jay

Carpe Ductum - Sieze the tape

*
* Texas PHP Developers Meeting  Spring 2003 *
* T Bar M Resort & Conference Center*
* New Braunfels, Texas  *
* Interested? Contact;  *
* [EMAIL PROTECTED]   *
*



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




RE: [PHP] mktime parameters (Was: Replacing Number with Month(newbie))

2002-05-31 Thread Jon Haworth

Hi Mike,

> > > Is there a magical function that I can use to convert 4 
> > > into April and 5 into May etc?
> > > can I use mktime()
> > > One yes no answer will do fine
> > 
> > Yes and no ;-)
> 
> Ha! I was just about to say exactly that myself!

It was just too tempting :-)

> Except, to get just the month (and leaving out 
> optional arguments to mktime()), you would need:
> date('F', mktime(12, 0, 0, $month));

Hmm. I thought this should work as well. This morning, though, I had to fix
a bug where a combo box was displaying something like

"January"
"March"
"March"
"April"
"May"
"May"

...

The code was


  ". date ("F", mktime (3, 0, 0, $i)). "";
}
  ?>


When I changed the mktime parameters to (3, 0, 0, $i, 1, 2002) it all worked
fine.

I think it's because it's the 31st today, and any months that don't have 31
days were getting screwed up (wouldn't mind hearing any other ideas though).
It seems like it's always a good idea to pass at least the day parameter to
mktime(), unless you enjoy unpredictable results ;-)

Cheers
Jon

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




Re: [PHP] mktime()

2002-05-17 Thread Rasmus Lerdorf

A couple of ways to do it:

strtotime('09 May 2002');

mktime(12,0,0,5,9,2002);


On Sat, 18 May 2002, Josh Edwards wrote:

> After reading the manual Istill can't convert this
> 09/May/2002 to a timestamp.
>
> Any Pointers
>
>
>
> --
> 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] mktime() into TIMESTAMP ?

2002-03-08 Thread DL Neil

Hi Erik,

> On Wednesday, March 6, 2002, at 05:11  AM, DL Neil wrote:
>
> > My 'rules' are simple:
> > If the date/time is for processing, keep it as a timestamp (consider
> > which type).
> >   If the timestamp is being used to keep track of RDBMS activity,
then
> > use a TIMESTAMP column.
>
> By RDBMS activity, do you mean "last time user performed x query" ?
> In fact, one of my columns is in fact designed to record things like
> "last time user logged in" or whatever, but I am not using the
> auto-bumping ability of the TIMESTAMP column, but rather creating a
new
> INSERT statement and mysql_query() function to do this job.

Either UPDATEing or INSERTing will cause an unspecified (first)
TIMESTAMP column to be set to NOW(). If it is recording last login, then
surely it makes more sense to UPDATE?

Yes, the TIMESTAMP 'bump' is useful to record 'last activity'
applications.

> >   If RDBMS auto-update would foul things up, use an integer data
type.

Whereas when I am recording timestamp data, but don't want the 'bump'
facility, then I store UNIX TIMESTAMPs in (suitably wide) INTEGER fields
(which won't 'bump' under any conditions).

> > If the date/time is for people/presentation, use a textural format.
>
> I'm thinking of not storing any plaintext dates, simply because it's
> easier to format the mktime() result or TIMESTAMP column to suit my
> needs.  In fact, combining mktime() and date() really seem to be the
way
> to go, which is why I'm using mktime()-generated Unix-style
> timestamps -- I'll probably never do any database output directly from
> mysql[client], but rather everything from PHP or perhaps Python if I
> ever get the time to work on that side project.*

Now if you mean UNIX TIMESTAMP as an integer (*not* MySQL TIMESTAMP)
that's exactly what I decided (excepting that I'm using PHP's GM*
functions and converting everything to UTC). The 'downside' is that
looking at the table contents is an eye-straining experience, so the
first thing you have to do is write a debug retrieval query that will
present the data in 'English'/a more readable form.

> >   If there will be minor processing on the column, eg GROUP BY,
ORDER
> > BY, or even >, =, etc, then use ISO format
> ISO = MySQL-style TIMESTAMP?
> If so, then can't you do ORDER BYs and >, = queries with the
Unix-style
> mktime()-generated integers as well?  I'm not very experienced with
the
> more advanced MySQL features, though I know they're there and have a
> decent reference should my script require them.

Careful! ISO dates are in CCYY-MM-DD format, as per MySQL DATEs.
MySQL TIMESTAMPs are in 'integer' format, still CCYYMMDD but don't try
using them for arithmetic!

Yes you are correct you can perform each of the above comparisons on
both data formats.

I didn't mean that you should interpret some 'exclusivity' in those
(somewhat informal) 'rules'. What I was saying was that the CCYY-MM-DD
format (cf TIMESTAMP) suits 'presentation' but can also be used for
simply manipulations, eg comparisons. However, backing up a paragraph or
two, I pointed out that the other temporal format is to be used when
calculations are required (and presentation is less of an issue). The
attempt was to illustrate when you might use one format and when the
other.

> >   If there will be no processing between what comes out of PHP and
what
> > PHP wants back, use a string format column.
>
> That's what I was thinking.  Apart from some simple queries for
results
> whose dates are between x and y (which should work with
> mktime()-generated timestamps, right?), it seems that this is the best
> policy.  I should change those columns from TIMESTAMP to INT now
before
> I go any further, just so that I don't accidentally ever bump up the
> value of the column via an insert or update...
>
> > Yes you should remember that MySQL will happily cast between string
and
> > integer alternative presentations!
>
> I'm not sure I understand what this means.  I'm guessing that you're
> suggesting that an INT or a VARCHAR column can both have mathematical
> operations performed on their values, but perhaps I'm completely
> off-base.  My SQL skills are miserable... I need to brush up.  (Too
much
> time spent learning PHP lately!)

"Cast" means to set/reset a value in one datatype/format to another
datatype, eg converting a character="1" to an integer=1, or as you say,
a TIMESTAMP value (of either kind) to an integer - or a string
DATE=CCYY-MM-DD to its integer equivalent=CCYYMMDD.

> > Your take/critique welcomed!
>
> More like questions than critique!

All encourages clarity of thinking and expression!

Regards,
=dn


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




Re: [PHP] mktime() into TIMESTAMP ?

2002-03-07 Thread Erik Price


On Wednesday, March 6, 2002, at 05:11  AM, DL Neil wrote:

> My 'rules' are simple:
>
> If the date/time is for processing, keep it as a timestamp (consider
> which type).
>   If the timestamp is being used to keep track of RDBMS activity, then
> use a TIMESTAMP column.

By RDBMS activity, do you mean "last time user performed x query" ?
In fact, one of my columns is in fact designed to record things like 
"last time user logged in" or whatever, but I am not using the 
auto-bumping ability of the TIMESTAMP column, but rather creating a new 
INSERT statement and mysql_query() function to do this job.

>   If RDBMS auto-update would foul things up, use an integer data type.
>
> If the date/time is for people/presentation, use a textural format.

I'm thinking of not storing any plaintext dates, simply because it's 
easier to format the mktime() result or TIMESTAMP column to suit my 
needs.  In fact, combining mktime() and date() really seem to be the way 
to go, which is why I'm using mktime()-generated Unix-style 
timestamps -- I'll probably never do any database output directly from 
mysql[client], but rather everything from PHP or perhaps Python if I 
ever get the time to work on that side project.*

>   If there will be minor processing on the column, eg GROUP BY, ORDER
> BY, or even >, =, etc, then use ISO format

ISO = MySQL-style TIMESTAMP?
If so, then can't you do ORDER BYs and >, = queries with the Unix-style 
mktime()-generated integers as well?  I'm not very experienced with the 
more advanced MySQL features, though I know they're there and have a 
decent reference should my script require them.

>   If there will be no processing between what comes out of PHP and what
> PHP wants back, use a string format column.

That's what I was thinking.  Apart from some simple queries for results 
whose dates are between x and y (which should work with 
mktime()-generated timestamps, right?), it seems that this is the best 
policy.  I should change those columns from TIMESTAMP to INT now before 
I go any further, just so that I don't accidentally ever bump up the 
value of the column via an insert or update...

> Yes you should remember that MySQL will happily cast between string and
> integer alternative presentations!

I'm not sure I understand what this means.  I'm guessing that you're 
suggesting that an INT or a VARCHAR column can both have mathematical 
operations performed on their values, but perhaps I'm completely 
off-base.  My SQL skills are miserable... I need to brush up.  (Too much 
time spent learning PHP lately!)

> Your take/critique welcomed!

More like questions than critique!



Erik







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


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




Re: [PHP] mktime() into TIMESTAMP ?

2002-03-06 Thread DL Neil

Erik,
Apologies, I missed your reply in the mass of mailings and a rushed
start to the week...

> > The choice comes down to how you are generating the time data prior
to
> > its storage in the db, and how you plan to use it afterwards. If you
are
> > going to be doing lots of temporal processing in PHP, then UNIX
> > timestamp is the way to go. If it is purely a 'label' then stick
with
> > that format - even storing a string in MySQL that it doesn't realise
is
> > a date! Both PHP and MySQL have a wide range of time/date functions
to
> > support such activities.
>
> Thanks David, I think I'm going to avoid potential problems with
> TIMESTAMP columns' unique features by just storing a PHP mktime()
value
> into a VARCHAR(15) column (advice from someone on this list, I can't
> remember who).  While it will mostly be a label, and I could take a
> shortcut, the advantage is that I can always reformat the Unix
timestamp
> (mktime()) for that later, and I plan to do searches based on date at
> times.


My 'rules' are simple:

If the date/time is for processing, keep it as a timestamp (consider
which type).
  If the timestamp is being used to keep track of RDBMS activity, then
use a TIMESTAMP column.
  If RDBMS auto-update would foul things up, use an integer data type.

If the date/time is for people/presentation, use a textural format.
  If there will be minor processing on the column, eg GROUP BY, ORDER
BY, or even >, =, etc, then use ISO format
  If there will be no processing between what comes out of PHP and what
PHP wants back, use a string format column.

Yes you should remember that MySQL will happily cast between string and
integer alternative presentations!

Your take/critique welcomed!

Regards,
=dn


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




Re: [PHP] mktime() into TIMESTAMP ?

2002-03-05 Thread Erik Price


On Monday, March 4, 2002, at 07:22  PM, DL Neil wrote:

> The choice comes down to how you are generating the time data prior to
> its storage in the db, and how you plan to use it afterwards. If you are
> going to be doing lots of temporal processing in PHP, then UNIX
> timestamp is the way to go. If it is purely a 'label' then stick with
> that format - even storing a string in MySQL that it doesn't realise is
> a date! Both PHP and MySQL have a wide range of time/date functions to
> support such activities.

Thanks David, I think I'm going to avoid potential problems with 
TIMESTAMP columns' unique features by just storing a PHP mktime() value 
into a VARCHAR(15) column (advice from someone on this list, I can't 
remember who).  While it will mostly be a label, and I could take a 
shortcut, the advantage is that I can always reformat the Unix timestamp 
(mktime()) for that later, and I plan to do searches based on date at 
times.

Erik





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


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




Re: [PHP] mktime() into TIMESTAMP ?

2002-03-04 Thread DL Neil

Erik,

> PHP's mktime() function uses a timestamp that is the number of seconds
> since the Unix epoch.  MySQL uses the MMDDhhmmss format for its
> TIMESTAMP column type.
>
> I'm not complaining that they're not the same, but curious as to which
I
> should use for storing timestamps -- does it matter?  PHP has a lot of

MySQL timestamps should be stored in a timestamp column - unless your
application runs contrary to the automatic updating rule. (Manual
6.2.2.2 The DATETIME, DATE, and TIMESTAMP Types)

> nice formatting conventions with date(), so I am leaning towards using
> mktime() to store PHP-style timestamps into a MySQL TIMESTAMP column.
> But MySQL does have the ability to format dates, and its TIMESTAMP
> column type bumps up if I don't manually insert a value.

Don't forget that you will need a UNIX call to translate the UNIX Epoch
timestamp from PHP integer into MySQL Timestamp format.

Would it not be easier to use FROM_UNIXTIME() and plug straight into a
MySQL DATETIME string column - with no danger of auto-update?

The choice comes down to how you are generating the time data prior to
its storage in the db, and how you plan to use it afterwards. If you are
going to be doing lots of temporal processing in PHP, then UNIX
timestamp is the way to go. If it is purely a 'label' then stick with
that format - even storing a string in MySQL that it doesn't realise is
a date! Both PHP and MySQL have a wide range of time/date functions to
support such activities.

Regards,
=dn


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




RE: [PHP] mktime() into TIMESTAMP ?

2002-03-04 Thread Alastair Battrick

Just make sure that whichever way you choose, you always use the same style,
so things don't get messy.

Personally, I always use INT(11) MySQL columns and store the unix timestamp
and this makes things easy for me. The only exception is when storing dates
that are before 1970, but I very rarely have to do this.

In the end, I guess it depends if you want to do the formatting of the date
field when you're inserting the data (use TIMESTAMP) or when you're pulling
it out (use INT).


Alastair Battrick
Lightwood Consultancy Ltd
http://www.lightwood.net

> -Original Message-
> From: Erik Price [mailto:[EMAIL PROTECTED]]
> Sent: 04 March 2002 22:12
> To: PHP (E-mail)
> Subject: [PHP] mktime() into TIMESTAMP ?
>
>
> PHP's mktime() function uses a timestamp that is the number of seconds
> since the Unix epoch.  MySQL uses the MMDDhhmmss format for its
> TIMESTAMP column type.
>
> I'm not complaining that they're not the same, but curious as to which I
> should use for storing timestamps -- does it matter?  PHP has a lot of
> nice formatting conventions with date(), so I am leaning towards using
> mktime() to store PHP-style timestamps into a MySQL TIMESTAMP column.
> But MySQL does have the ability to format dates, and its TIMESTAMP
> column type bumps up if I don't manually insert a value.
>
> Any suggestions?
>
>
> Erik
>
>
>
>
> 
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


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




Re: [PHP] mktime() Algorithm

2002-02-06 Thread Lars Torben Wilson

On Wed, 2002-02-06 at 11:28, David A Dickson wrote:
> I need to create a function in another programming language that takes the
> same input as the php mktime() function and produces the exact same output
> as the php mktime() function. Does anybody out there know what the
> algorithm is?
> 
> -- 
> David A Dickson
> [EMAIL PROTECTED]

Sure: it starts around line 80 on ext/standard/datetime.c in the
source tree:

  http://cvs.php.net/co.php/php4/ext/standard/datetime.c?r=1.82


Hope this helps,

Torben

-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


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




Re: [PHP] mktime() problem

2001-10-23 Thread DL Neil

So do I:
 echo "Mkt: " . mktime(0,0,0,1,1,1970);
 echo "GMT: " . gmmktime(0,0,0,1,1,1970);
produces
 Mkt: 0
 GMT: -3600
BTW I'm running PHP under WinNT4.0

mktime -- Get UNIX timestamp for a date 
(http://www.php.net/manual/en/function.mktime.php)
Returns the Unix timestamp corresponding to the arguments given. This timestamp is a 
long integer containing the number
of seconds between the Unix Epoch (January 1 1970) and the time specified.

gmmktime -- Get UNIX timestamp for a GMT date 
(http://www.php.net/manual/en/function.gmmktime.php)
Identical to mktime() except the passed parameters represents a GMT date.

Given that 1Jan1970 was not in Summer time, I would expect that a localised British 
(etc) machine would deliver the same
answer from both functions. So there's some logic here that I don't follow either. 
Perhaps someone of greater mind...?

I will send you a sandbox routine I made up when I was playing with times and dates, 
and trying to get a handle on
working in GMT to settle (WORLD wide web) relative time-ing issues. It's not flash, 
but happily dumps out various
date/time function results and illustrates the various argument/format choices (I'm 
not sure of list rules, so I'll send
it privately - if anyone else wants it, please email me directly. HTH). Run it today - 
you'll get the "rd" after 23rd,
and this week - to get a GMT/BST difference!

Here's a sample run:
--
UNIX microtime=0.26452800 1003852812~

UNIX epoch timestamp=1003852812~
Alternative method=1003852812~

Local/RFC=Tue, 23 Oct 2001 17:00:12 +0100~
Local/Times: hh/HH:mm:ss=05/17:00:12~
Local/Days: d, dd, ddd, day, Su0Sa6=23,23,Tue,Tuesday,2~
Local/Months: long, mmm, mm=October,Oct,10~
Local/Years: , yy=2001,01~
Local/Booleans: DST,Lyr=1,0~
Local/Misc: AM/PM, am/pm, st/nd, days/mmm, day/yr=PM,pm,rd,31,295~
Local/TimeZones: diffGMT, PC-TZ, offset=+0100,,3600~

Date to Timestamp=1003852812~

GMT/RFC=Tue, 23 Oct 2001 16:00:12 +~
GMT/Times: hh/HH:mm:ss=04/16:00:12~
GMT/Days: d, dd, ddd, day, Su0Sa6=23,23,Tue,Tuesday,2~
GMT/Months: long, mmm, mm=October,Oct,10~
GMT/Years: , yy=2001,01~
GMT/Booleans: DST,Lyr=0,0~
GMT/Misc: AM/PM, am/pm, st/nd, days/mmm, day/yr=PM,pm,rd,31,295~
GMT/TimeZones: diffGMT, PC-TZ, offset=+,,0~

Date to GMT Timestamp=1003849212~

UNIX microtime=0.00617600 1003852813~
--

Regards,
=dn



> Oh dear, I still get -3600 when I do
>
> echo gmmktime(0,0,0,1,1,1970);
>
> Why?
>
> James
>
> -Original Message-
> From: Fairbairn,J,James,IVLH4 C
> Sent: 23 October 2001 13:57
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] mktime() problem
>
>
> Thanks, I'll use gmmktime() from now on!
>
> James
>
> -Original Message-----
> From: DL Neil [mailto:[EMAIL PROTECTED]]
> Sent: 23 October 2001 13:54
> To: Fairbairn,J,James,IVLH4 C; php-general
> Subject: Re: [PHP] mktime() problem
>
>
> > I'm running 4.0.6 on a Solaris 8 box. The output given by
> > echo mktime(0,0,0,1,1,1970);
> > is 3600.
> >
> > Shouldn't it be 0? My box's locale is set to the UK defaults, so as I
> write
> > this we are in daylight savings (GMT+1). Would this make a difference? (I
> > have already tried
> > echo mktime(0,0,0,1,1,1970,0);
> > to force non-daylight-savings, but I still get 3600.) Am I doing something
> > wrong, or have I found a bug?
>
>
> James,
> Had to worry about this too!
> Try comparing gmmktime() and mktime().
> Regards,
> =dn
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP 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] mktime() problem

2001-10-23 Thread james . fairbairn

Oh dear, I still get -3600 when I do

echo gmmktime(0,0,0,1,1,1970);

Why?

James

-Original Message-
From: Fairbairn,J,James,IVLH4 C 
Sent: 23 October 2001 13:57
To: [EMAIL PROTECTED]
Subject: RE: [PHP] mktime() problem


Thanks, I'll use gmmktime() from now on!

James

-Original Message-
From: DL Neil [mailto:[EMAIL PROTECTED]]
Sent: 23 October 2001 13:54
To: Fairbairn,J,James,IVLH4 C; php-general
Subject: Re: [PHP] mktime() problem


> I'm running 4.0.6 on a Solaris 8 box. The output given by
> echo mktime(0,0,0,1,1,1970);
> is 3600.
> 
> Shouldn't it be 0? My box's locale is set to the UK defaults, so as I
write
> this we are in daylight savings (GMT+1). Would this make a difference? (I
> have already tried
> echo mktime(0,0,0,1,1,1970,0);
> to force non-daylight-savings, but I still get 3600.) Am I doing something
> wrong, or have I found a bug?


James,
Had to worry about this too!
Try comparing gmmktime() and mktime().
Regards,
=dn


-- 
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] mktime() problem

2001-10-23 Thread james . fairbairn

Thanks, I'll use gmmktime() from now on!

James

-Original Message-
From: DL Neil [mailto:[EMAIL PROTECTED]]
Sent: 23 October 2001 13:54
To: Fairbairn,J,James,IVLH4 C; php-general
Subject: Re: [PHP] mktime() problem


> I'm running 4.0.6 on a Solaris 8 box. The output given by
> echo mktime(0,0,0,1,1,1970);
> is 3600.
> 
> Shouldn't it be 0? My box's locale is set to the UK defaults, so as I
write
> this we are in daylight savings (GMT+1). Would this make a difference? (I
> have already tried
> echo mktime(0,0,0,1,1,1970,0);
> to force non-daylight-savings, but I still get 3600.) Am I doing something
> wrong, or have I found a bug?


James,
Had to worry about this too!
Try comparing gmmktime() and mktime().
Regards,
=dn


-- 
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] mktime() problem

2001-10-23 Thread DL Neil

> I'm running 4.0.6 on a Solaris 8 box. The output given by
> echo mktime(0,0,0,1,1,1970);
> is 3600.
> 
> Shouldn't it be 0? My box's locale is set to the UK defaults, so as I write
> this we are in daylight savings (GMT+1). Would this make a difference? (I
> have already tried
> echo mktime(0,0,0,1,1,1970,0);
> to force non-daylight-savings, but I still get 3600.) Am I doing something
> wrong, or have I found a bug?


James,
Had to worry about this too!
Try comparing gmmktime() and mktime().
Regards,
=dn



-- 
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] mktime + 4 days

2001-02-13 Thread PHPBeginner.com

$time = time();

$timePlus4Days = $time + 60*60*24*4;

$tomorrow = date ("d", $timePlus4Days);


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Christopher Allen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 13, 2001 2:06 PM
To: php
Subject: [PHP] mktime + 4 days


Hi!
How to get this to work for every month:

$tomorrow = date ("d", mktime(0,0,0,0,date("d") +4 ) );  
echo "Today + 4 days  is $tomorrow ";
screws up Feb et al


Thanks,

Christopher C. M. Allen


-- 
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] mktime + 4 days

2001-02-13 Thread Jason Stechschulte

On Mon, Feb 12, 2001 at 11:06:16PM -0600, Christopher Allen wrote:
> $tomorrow = date ("d", mktime(0,0,0,0,date("d") +4 ) );  
> echo "Today + 4 days  is $tomorrow ";
> screws up Feb et al

If you add the month and year, it should work just fine.

$tomorrow = date ("d", mktime(0,0,0,date("m"),date("d") +4,date("Y")));


-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
It's all magic.  :-)
 -- Larry Wall in <[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] mktime() not allowing dates before 1970

2001-01-25 Thread Monte Ohrt

use Date_Calc.

http://www.phpinsider.com/php/code/Date_Calc/

Diego Fulgueira wrote:
> 
> I know the UNIX epoch is 1/1/1970 and that mktime() returns the number of
> seconds between that date and the date specified by its parameters. If this
> date is before 1/1/1970, it always returns -1, not a large negative number,
> which would be more reasonable, i think.
> The question is: How can I know the number of seconds ellapsed between any
> date in the past and today?
> 
> Thanks in advance.
> 
> --
> 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]

--
Monte Ohrt <[EMAIL PROTECTED]>
http://www.ispi.net/

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