Re: [PHP] Re: Date validation

2011-05-23 Thread Pete Ford

On 23/05/11 13:12, tedd wrote:

At 9:47 AM +0100 5/23/11, Pete Ford wrote:

Finally, for some applications I have made an AJAX (javascript + PHP)
implementation which provides feedback to the user as they type in the
date field: every time a character is typed in the box, the backend is
asked to parse it and then format it in an unambiguous way and send it
back to the client. That way the user can *see* if what they are
typing is valid...
Of course, you *still* have to validate it when it's posted (and the
network overhead might be too much).


That would be interesting to see.

With a little work, I envision a way to alleviate the Europe/US date
format difference. (i.e., day/month/year : Europe vs month/day/year : US).

As the user typed in the date, the day/month problem could be shown via
string-month (i.e., Jan... ).

How does yours work?

Cheers,

tedd


Ah, now you're asking.
I'll have to try and extract the code into a sanitised form for public 
consumption: give me a little time...
But yes, the string fed back to the user gives the month as a string, to avoid 
confusion with numeric months.


--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Re: Date validation

2011-05-23 Thread Tamara Temple

Isn't this typically why date selectors are used on the front end?

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



Re: [PHP] Re: Date validation

2011-05-23 Thread Andrew Ballard
On Mon, May 23, 2011 at 9:55 AM, Tamara Temple tamouse.li...@gmail.com wrote:
 Isn't this typically why date selectors are used on the front end?


Not really. Date selectors are intended to make data entry easier on
the front end while allowing only valid date selections, but you can't
really rely on them.

* Most date selectors rely on Javascript, which may not be available
on the client.

* From a usability perspective, using a date selector is slower than
typing the date into a text field. Accessibility is also a concern.

* Above all, your code should still validate the correctness of input
on the server regardless of anything you are doing to make things
easier in the client. There are ways around using date selectors.

Andrew

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



Re: [PHP] Re: Date validation

2011-05-20 Thread Peter Lind
On 20 May 2011 16:22, Geoff Lane ge...@gjctech.co.uk wrote:
  On Friday, May 20, 2011, João Cândido de Souza Neto wrote:

 What about using this:

 $date = DateTime::createFromFormat(Y-m-d, 2011-05-20);

 Hi João, and thanks for your help.

 FWIW, I thought about that but it didn't work for me. On further
 investigation, I'm now completely confused and suspect I've got a duff
 PHP installation. Thankfully, it's a virtual machine so it should be
 reasonable easy to 'vapourise' and start over (perhaps with CentOS
 rather than Ubuntu as the OS).

 Anyway, the following code produces the following result when the
 variable $str = '7 feb 2010':

 [code]
  echo pDate is $str/p\n;
  $date = DateTime::createFromFormat('d M Y', $str);
  echo pre;
  print_r($date);
  echo /pre\n;
  echo date('d M Y') . br / . date('d M Y', $date);
 [/code]

 [result]
  pDate is 7 feb 2010/p
  preDateTime Object
  (
      [date] = 2010-02-07 15:11:34
      [timezone_type] = 3
      [timezone] = Europe/London
  )
  /pre
  20 May 2011br /
 [/result]

 This is pretty much as expected except that the second call to date()
 - i.e. date('d M Y', $date) - outputs nothing.

date() takes an int as second parameter - a timestamp. Not an object.
And from a quick test it doesn't look like DateTime has a __toString
method.

 Also, AFAICT createFromFormat fails if the date is not formatted
 according to the first parameter. So, for example:
  $date = DateTime::createFromFormat('d M Y', '5/2/10')
 fails ... (at least, it does on my system :( )


I'm sorry for asking but what did you expect?? You're specifically
calling a method that parses a string according to a given format. If
it parsed the string according to any other format, that would be a
huge WTF.

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP] Re: Date validation

2011-05-20 Thread Jo�o C�ndido de Souza Neto
If you look carefully, you´ll notice that I´m using the DateTime object 
(default from PHP 5.2.0 or higher) not the function date.

-- 
João Cândido de Souza Neto

Peter Lind peter.e.l...@gmail.com escreveu na mensagem 
news:banlktinjonyvfnqjqtfqtdmu_r2-cfp...@mail.gmail.com...
On 20 May 2011 16:22, Geoff Lane ge...@gjctech.co.uk wrote:
 On Friday, May 20, 2011, João Cândido de Souza Neto wrote:

 What about using this:

 $date = DateTime::createFromFormat(Y-m-d, 2011-05-20);

 Hi João, and thanks for your help.

 FWIW, I thought about that but it didn't work for me. On further
 investigation, I'm now completely confused and suspect I've got a duff
 PHP installation. Thankfully, it's a virtual machine so it should be
 reasonable easy to 'vapourise' and start over (perhaps with CentOS
 rather than Ubuntu as the OS).

 Anyway, the following code produces the following result when the
 variable $str = '7 feb 2010':

 [code]
 echo pDate is $str/p\n;
 $date = DateTime::createFromFormat('d M Y', $str);
 echo pre;
 print_r($date);
 echo /pre\n;
 echo date('d M Y') . br / . date('d M Y', $date);
 [/code]

 [result]
 pDate is 7 feb 2010/p
 preDateTime Object
 (
 [date] = 2010-02-07 15:11:34
 [timezone_type] = 3
 [timezone] = Europe/London
 )
 /pre
 20 May 2011br /
 [/result]

 This is pretty much as expected except that the second call to date()
 - i.e. date('d M Y', $date) - outputs nothing.

date() takes an int as second parameter - a timestamp. Not an object.
And from a quick test it doesn't look like DateTime has a __toString
method.

 Also, AFAICT createFromFormat fails if the date is not formatted
 according to the first parameter. So, for example:
 $date = DateTime::createFromFormat('d M Y', '5/2/10')
 fails ... (at least, it does on my system :( )


I'm sorry for asking but what did you expect?? You're specifically
calling a method that parses a string according to a given format. If
it parsed the string according to any other format, that would be a
huge WTF.

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype 



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



Re: [PHP] Re: Date validation

2011-05-20 Thread Peter Lind
2011/5/20 João Cândido de Souza Neto j...@consultorweb.cnt.br:
 If you look carefully, you´ll notice that I´m using the DateTime object
 (default from PHP 5.2.0 or higher) not the function date.

If you look carefully, you'll notice that I replied to Geoff.

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP] Re: Date validation

2011-05-20 Thread Peter Lind
On 20 May 2011 16:47, Geoff Lane ge...@gjctech.co.uk wrote:

*snip*

 Also, AFAICT createFromFormat fails if the date is not formatted
 according to the first parameter. So, for example:
  $date = DateTime::createFromFormat('d M Y', '5/2/10')
 fails ... (at least, it does on my system :( )


 I'm sorry for asking but what did you expect?? You're specifically
 calling a method that parses a string according to a given format. If
 it parsed the string according to any other format, that would be a
 huge WTF.

 Don't feel sorry to have asked, because it's exactly what I expected.
 João suggested using createFromFormat. Since I need to validate dates
 input in any valid form, I felt it wouldn't work and my comment was to
 João to that effect. That said, I've seen some weird and unexpected
 results from my development server recently (e.g. my post of 16 May re
 weird cookie behaviour) which was why I added the proviso (at least,
 it does on my system) just in case that method wasn't meant to behave
 as I inferred.

 With all that said, I still have no 'out of the box' method to
 validate a user-input date string and I haven't been able to find the
 code I used with PHP 3.something before my sojourn into the depths of
 ASP to know how I used to do this!


My bad, I jumped into the middle of a thread - sorry.

Try:

$date = new DateTime($date_string_to_validate);
echo $date-format('Y-m-d');

Regards
Peter

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



Re: [PHP] Re: date() and timezone

2006-12-15 Thread Fernando M. M.


Hello,


 But like i said i have lots of scripts inside
this
 folder, is there a way to set something on .htaccess to change
the timezone?

 
 why? ;-)

Because i can't set
the timezone for every single script. Inside this folder and subfolders i guess 
there
are about 10,000 scripts.

 What you were pointed to before + 
  http://us3.php.net/manual/de/ini.php#ini.list
 
 ah, now
you've gone and made it easy for him :-)
 

Actually i don't have
access to php.ini file. Are there any other ways to do this?

-- 

Blog: http://blog.forumdebian.com.br/fernando
Contato:
http://www.forumdebian.com.br/fernando/contato.php


Re: [PHP] Re: date() and timezone

2006-12-15 Thread Jochem Maas
Fernando M. M. wrote:
 
 Hello,
 
 
 But like i said i have lots of scripts inside
 this
 folder, is there a way to set something on .htaccess to change
 the timezone?
 why? ;-)
 
 Because i can't set
 the timezone for every single script. Inside this folder and subfolders i 
 guess there
 are about 10,000 scripts.

that will teach not to use global include files to init your apps.

even if you we stuck with editing 10,000 scripts (btw it sounds very fishy
to 10,000 scripts with date() calls in them - can anyone say 'code reuse'?)
exactly how hard would it be to write something that would go through all
those php files and add a single line ( ini_set('date.timezone', 
'Europe/Amsterdam'); )
to the top of the script (i.e. just after the first '?php' | '?') ?

 
 What you were pointed to before + 
  http://us3.php.net/manual/de/ini.php#ini.list
 ah, now
 you've gone and made it easy for him :-)
 
 Actually i don't have
 access to php.ini file. 

if you RTFM (and I mean actually READ) then you would know that you
can set the relevant date related ini settings in a .htaccess file

here is the relevant link again:

http://php.net/manual/en/ref.datetime.php#ini.date.timezone


 Are there any other ways to do this?
 


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



Re: [PHP] Re: date() and timezone

2006-12-15 Thread Fernando M. M.


 
 that will teach not to use global include files to init your apps.
 
 even if you we stuck with editing 10,000 scripts (btw it sounds very
fishy
 to 10,000 scripts with date() calls in them - can anyone say 'code
reuse'?)
 exactly how hard would it be to write something that would go through
all
 those php files and add a single line ( ini_set('date.timezone',
'Europe/Amsterdam');
 )
 to the top of the script (i.e. just
after the first '?php' | '?') ?

Those scripts are uploaded by a lot
of people. Unfortunately i can't make all of them change this conf. But now i 
know that
i can change this on .htaccess


 
 if you RTFM (and I mean
actually READ) then you would know that you
 can set the relevant date related
ini settings in a .htaccess file
 
 here is the relevant link
again:
 

http://php.net/manual/en/ref.datetime.php#ini.date.timezone
 
 

Sorry, i have read it but i was reading the portuguese version and it seens like
it is not completely translated. Just changed to the english version and NOW i 
can read
it :)

Thanks,

Fernando.
-- 

Blog:
http://blog.forumdebian.com.br/fernando
Contato:
http://www.forumdebian.com.br/fernando/contato.php


Re: [PHP] Re: date() and timezone

2006-12-15 Thread Jochem Maas
Fernando M. M. wrote:
 
 that will teach not to use global include files to init your apps.

 even if you we stuck with editing 10,000 scripts (btw it sounds very
 fishy
 to 10,000 scripts with date() calls in them - can anyone say 'code
 reuse'?)
 exactly how hard would it be to write something that would go through
 all
 those php files and add a single line ( ini_set('date.timezone',
 'Europe/Amsterdam');
 )
 to the top of the script (i.e. just
 after the first '?php' | '?') ?
 
 Those scripts are uploaded by a lot
 of people. Unfortunately i can't make all of them change this conf. 

I was suggesting you write a script to programmatically hack all the files in 
question,
but its a moot point you've seen that there is a sane way of tackling the issue.

 But now i know that
 i can change this on .htaccess
 
 
 if you RTFM (and I mean
 actually READ) then you would know that you
 can set the relevant date related
 ini settings in a .htaccess file
 here is the relevant link
 again:

   http://php.net/manual/en/ref.datetime.php#ini.date.timezone

 
 Sorry, i have read it but i was reading the portuguese version and it seens 
 like
 it is not completely translated. Just changed to the english version and NOW 
 i can read
 it :)

ah that explains alot - my advice is always use the english version of the 
manual if you can,
no disrespect to the many hard-working translators out there but there is 
almost no chance any
translation team can keep up the number and frequency of updates to the docs.

for the same reason I recommend never using an offline version of the manual 
unless you
have no other choice.

 
 Thanks,
 
 Fernando.

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



Re: [PHP] Re: date() and timezone

2006-12-14 Thread Jochem Maas
Jonesy wrote:
 On Thu, 14 Dec 2006 16:56:55 -0200 (BRST), Fernando M. M. wrote:
 --=_20061214165655_35409
 Content-Type: text/plain; charset=iso-8859-1
 Content-Transfer-Encoding: 8bit

 I´m using php5 here.

 But like i said i have lots of scripts inside this
 folder, is there a way to set something on .htaccess to change the timezone?
 

why? ;-)

 Please don't top post.
 
 RTFM you were pointed to: Instead of using this function to set the 
 default timezone in your script, you can also use the INI setting 
 date.timezone to set the default timezone.
 
 What you were pointed to before + 
  http://us3.php.net/manual/de/ini.php#ini.list

ah, now you've gone and made it easy for him :-)

 
 Jonesy

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



Re: [PHP] Re: Date Question [SOLVED]

2006-03-17 Thread Tom Chubb
Thanks guys.

On 17/03/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote:

 select date_format(date,%d/%m/%y) as date from table

 It'll show in 17/03/06 format

 select date_format(date,%d/%m/%Y) as date from table

 It'll show in 17/03/2006 format


 Tom Chubb wrote:

  Please can you help me. I've created a page where problems are posted
 into
  a database and I am using the datetime format in MySQL and trying to
 find
  the best way to display it in the 17/03/06 format.
  I've found a way of doing it (so you don't think I haven't googled,
 RTFM)
  but don't think it's the best way.
  Any help would be appreciated.
 
  (Current Code:)
 
  ?php
  $datestr = $row_rsSnags['date'];
  $arr1 = str_split($datestr, 2);
  echo $arr1 [2];
  echo /;
  echo $arr1 [1];
  echo /;
  echo $arr1 [0];
  //  echo $row_rsSnags['date'];
  ?

 --
 ---
 João Cândido de Souza Neto
 Web Developer

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




--
Tom Chubb
[EMAIL PROTECTED]
07915 053312


Re: [PHP] Re: date problem

2005-06-29 Thread Mario netMines
Isn't DATEDIFF() a MySQL 4.x function? The server I'm using has 3.x and I 
can't upgrade...


- Original Message - 
From: Jasper Bryant-Greene [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, June 29, 2005 7:49 AM
Subject: Re: [PHP] Re: date problem



Mario netMines wrote:

Hi Jasper and thanks for the quick reply.

something tells me it's not a straightforward SQL query that I have to
use here but a logic using PHP and SQL.


Please don't top-post.

It can be done in SQL quite easily, as can many things people use PHP
for. Go to the MySQL manual at http://dev.mysql.com/ and read up on
Date/Time functions, specifically the DATEDIFF() function. IIRC, it
returns the difference between two dates.

You can perform many types of arithmetic on the return value of the
function which should help to get the result you want. Try the MySQL
mailing lists if you can't figure it out, or if you're completely stuck
and are *convinced* it's a PHP problem (which I doubt, but I could be
wrong) then by all means come back!

Cheers

Jasper

--
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] Re: date problem

2005-06-28 Thread Mario netMines

Hi Jasper and thanks for the quick reply.

something tells me it's not a straightforward SQL query that I have to use 
here but a logic using PHP and SQL.


Mario
- Original Message - 
From: Jasper Bryant-Greene [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, June 29, 2005 4:28 AM
Subject: [PHP] Re: date problem



Firstly, this shouldn't be in the PHP list, as you're asking for help
with SQL.

Mario netMines wrote:

carrental_from (datetime field)
carrental_to (datetime field)
carrental_price (datetime field) [rates are per hour]


carrental_price shouldn't be a datetime field, as it isn't a datetime 
value.



The values I have are like:
-00-00 00:00:00,-00-00 07:00:00,10 (all year around 00:00-07:00)
-00-00 07:00:00,-00-00 00:00:00,20 (all year around 07:00-00:00)
2005-12-22 07:00:00,2006-01-02 00:00:00,15 (christmas period 00:00-07:00)
2005-12-22 00:00:00,2006-01-02 07:00:00,25 (christmas period 07:00-00:00)

The user selects dates ($from - $to) to rent a car and he gets the price
accordingly.
I can do a (($to-$from)/60/60) and get the total number of hours but
depending on the date and time you get a different result. Can anyone
help with the SQL?


Read up on the MySQL DATEDIFF() function, if you are using MySQL. Other
DBMSs should have an equiv. function.

Jasper

--
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] Re: date problem

2005-06-28 Thread Jasper Bryant-Greene
Mario netMines wrote:
 Hi Jasper and thanks for the quick reply.
 
 something tells me it's not a straightforward SQL query that I have to
 use here but a logic using PHP and SQL.

Please don't top-post.

It can be done in SQL quite easily, as can many things people use PHP
for. Go to the MySQL manual at http://dev.mysql.com/ and read up on
Date/Time functions, specifically the DATEDIFF() function. IIRC, it
returns the difference between two dates.

You can perform many types of arithmetic on the return value of the
function which should help to get the result you want. Try the MySQL
mailing lists if you can't figure it out, or if you're completely stuck
and are *convinced* it's a PHP problem (which I doubt, but I could be
wrong) then by all means come back!

Cheers

Jasper

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



Re: [PHP] Re: Date()

2005-01-17 Thread Steve Buehler
At 08:33 PM 1/15/2005, you wrote:
Torsten,
Whatever the combination, it echos February 02-2005brFebruary 
02-2005brFebruary 02-2005. What is wrong with it?

  ?php
  $week5 = 2005-02-14;
  $firstDayTs = strtotime($week5);
  $lastDayTs = $firstDayTs + (4 * 86400);
  echo date('F', $firstDayTs) . ' ' . date('m', $firstDayTs) . '-' . 
date('Y',$firstDayTs) .br;
  echo date('F', $firstDayTs) . ' ' . date('m', $firstDayTs) . '-' . 
date('Y',$lastDayTs) .br;
  ?

John
It is outputing what you are asking it to:
FA full textual representation of a month, such as January or March
mNumeric representation of a month, with leading zeros
YA full numeric representation of a year, 4 digits
This is all documented at: http://us2.php.net/manual/en/function.date.php
First you are asking for the Month as a name, then the month as a number 
then the year as a number.  If you made $week5=2005-12-31 it would give you 
the following output:
December 12-2005brDecember 12-2006br
If you are wanting to make it echo February 14-18, then check out the 3rd 
echo statement in the below example.

?php
  $week5 = 2005-02-14;
  $firstDayTs = strtotime($week5);
  $lastDayTs = $firstDayTs + (4 * 86400);
  echo date('F', $firstDayTs) . ' ' . date('d', $firstDayTs) . '-' . 
date('Y',$firstDayTs) .br\n;
  echo date('F', $lastDayTs) . ' ' . date('d', $lastDayTs) . '-' . 
date('Y',$lastDayTs) .br\n;
  echo date('F', $lastDayTs) . ' ' . date('d', $firstDayTs) . '-' . 
date('d',$lastDayTs) .br\n;
echo \n;
  ?
Now, the problem with that is that if your $week5=2005-02-18 then your 
results will be wrongunless this is what you want, but the answer will 
be February 28-04.  You are outputing the Month from $week5, the day from 
$week5 and the day+4 of $week5 which takes it into the next month.

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


Re: [PHP] Re: Date Conversions?

2004-11-15 Thread Robert Sossomon
Matthew Weier O'Phinney is quoted as saying on 11/15/2004 3:01 PM:
* Robert Sossomon [EMAIL PROTECTED]:
SNIP
http://php.net/strtotime
Specifically, try the following:
// $date is the date as pulled from the MySQL table
$convertedDate = date(m-d-y, strtotime($date));
Here's what I wound up using, in case anyone else comes across the same 
dilemma:
$Date = $Quote['Date'];
$EDate = date(M d, Y,strtotime($Date));

--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Date and time

2004-08-11 Thread Matthew Sims
 There was a little mistake in the code I posted before, try this one:

 http://aidan.dotgeek.org/lib/?file=function.convert_timestamp.php


 Diff Fannehh [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi,

 I have this date in timestamp format:

 $a= 20040810114155;

 I want to add 7 days to this date. How can i do that?

 Thanks



Isn't it considered faster to let the database do the conversion to Unix
Timestamp?

-- 
--Matthew Sims
--http://killermookie.org

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



Re: [PHP] Re: Date Function - Empty Value

2004-05-20 Thread Mark Pecaut
On Thu, May 20, 2004 at 12:28:00PM -0400, Gabe wrote:
 I'm trying to store a date in a date/time field using the short date
 format ( m/d/ ).  For some reason it won't let me post an empty
 value to that field in the DB.  I've tried using empty quotes (  )
 
 I'm using Microsoft Access for my database not MySQL.  Does that change 
 what I need to do?

Access delimits dates with '#' hash marks.  Try something like:

UPDATE tablename SET date_field=#9/30/2003# WHERE foo='bar';

or

UPDATE tablename SET date_field=NULL WHERE foo='bar';

if you want to make that field null.  If it complains when you try to
set it NULL and you want it to be null, put 'No' for 'Required' for that
field in Design View.

-Mark

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



Re: [PHP] Re: Date Function - Empty Value

2004-05-20 Thread Gabe
Mark Pecaut wrote:
On Thu, May 20, 2004 at 12:28:00PM -0400, Gabe wrote:
I'm trying to store a date in a date/time field using the short date
format ( m/d/ ).  For some reason it won't let me post an empty
value to that field in the DB.  I've tried using empty quotes (  )
I'm using Microsoft Access for my database not MySQL.  Does that change 
what I need to do?

Access delimits dates with '#' hash marks.  Try something like:
UPDATE tablename SET date_field=#9/30/2003# WHERE foo='bar';
or
UPDATE tablename SET date_field=NULL WHERE foo='bar';
if you want to make that field null.  If it complains when you try to
set it NULL and you want it to be null, put 'No' for 'Required' for that
field in Design View.
-Mark
I'll give those a try.  Thanks for the tips.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Date Function - Empty Value

2004-05-19 Thread Gabe
Matt Matijevich wrote:
[snip]
Well, I would, but I can't seem to figure out how to export just the 
structure out of access.  Wouldn't NULL be allowed by default?
[/snip]

Do you have access to the mdb file?  If you do you can just go into
design view of the table to find out the data definitions.
I do have access to the mdb but there's no way for me to export the 
structure that I'm looking at so I can send it to other people.  Or do 
you know of a way?

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


Re: [PHP] Re: date

2004-02-20 Thread Richard Davey
 how do i make php give me yesterday's date?

 i tried

 date(Y-m-d)-1

LC date('Y-m-d', time()- 60*60*24);
LC You could also use mktime.

Someone has already advised you look at strtotime, but just incase you
haven't here is one way you can use it:

$yesterdays_timestamp = strtotime(-1 day);

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] Re: date() funtion language

2004-02-13 Thread André Cerqueira
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
ohhh
thanks hehe
Don Read wrote:
On 12-Feb-2004 André Cerqueira wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
i had problems with locale
i think its safer to make a dayname and monthname array, and use
getdate(), than build the string yourself


snip

//the follow should, but doesnt seem to work
//setlocale(LC_ALL, 'pt_BR');
//echo date('l, j de F de Y');
?


date() doesn't format according to locale but strftime() does:

setlocale(LC_ALL, 'pt_BR.ISO8859-1');
echo strftime('%A, %B %e %Y');
// output 'Quinta Feira, Fevereiro 12 2004'



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFALQ4vaxdA/5C8vH8RAullAKDRwh4XpJg/lbZymdgW2fI+C2XbHwCfT5E+
6kGxyTlAnBjWvZGy1XT5YSY=
=mYsa
-END PGP SIGNATURE-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: date() funtion language

2004-02-13 Thread André Cerqueira
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
hmz...
i just tryed that... didnt work
tryed other locale strings, didnt work...
do i need something else to make it work?
running php4.3.4rc3 on windows


Don Read wrote:

On 12-Feb-2004 André Cerqueira wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
i had problems with locale
i think its safer to make a dayname and monthname array, and use
getdate(), than build the string yourself


snip

//the follow should, but doesnt seem to work
//setlocale(LC_ALL, 'pt_BR');
//echo date('l, j de F de Y');
?


date() doesn't format according to locale but strftime() does:

setlocale(LC_ALL, 'pt_BR.ISO8859-1');
echo strftime('%A, %B %e %Y');
// output 'Quinta Feira, Fevereiro 12 2004'



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFALQ73axdA/5C8vH8RAt+IAKCuAH1hlInsMdcwkNvFmJy119YC/ACg0uws
uvW3FtqgRSXl5VkOcPVgTls=
=3cMI
-END PGP SIGNATURE-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: date() funtion language

2004-02-12 Thread Don Read

On 12-Feb-2004 André Cerqueira wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 i had problems with locale
 i think its safer to make a dayname and monthname array, and use
 getdate(), than build the string yourself
 

snip

 
 //the follow should, but doesnt seem to work
 //setlocale(LC_ALL, 'pt_BR');
 //echo date('l, j de F de Y');
 ?

date() doesn't format according to locale but strftime() does:

setlocale(LC_ALL, 'pt_BR.ISO8859-1');
echo strftime('%A, %B %e %Y');

// output 'Quinta Feira, Fevereiro 12 2004'



-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] Re: date problem

2003-09-24 Thread Robert Cummings
From the documentation:

http://ca2.php.net/manual/en/function.mktime.php

Date with year, month and day equal to zero is considered
 illegal (otherwise it what be regarded as 30.11.1999, which
 would be strange behavior).

I think the point here to think about is that the date(), time(), and
mktime() functions all work with timestamps which happen to all function
with respect to the Unix Epoch (January 1 1970)

Cheers,
Rob.

On Wed, 2003-09-24 at 13:26, John wrote:
 For me, on Windows, it won't work because Windows won't do anything prior to
 1970.
 
 On linux, I get 17 as the result. If I change the year to 2000, then I get
 08 on both.
 
 John
 
 
 Shaun [EMAIL PROTECTED] wrote in message
 news:[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));
 
  Thanks for your help
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Re: Date Question.

2003-03-05 Thread Sebastian
can you give an example? I am stil learning :)

- Original Message -
From: Philip Hallstrom [EMAIL PROTECTED]


| Strip off the H:i:s part using explode() and use date() to get an
| equivalent string for right now and if they match, today's the day.
|
| On Wed, 5 Mar 2003, Sebastian wrote:
|
|  I have a date field in mysql in this format: Y-m-d H:i:s
| 
|  I would like to echo Today if the date is today, can someone offer
some
|  help? Thanks.


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



Re: [PHP] Re: Date Question.

2003-03-05 Thread Kevin Stone
He's recommending something like this..

$tmp = explode(' ', $date);
if (date(Y-m-d) == $tmp[0])  // date format -mm-dd
{
echo Today;
}

Seems like a reasonable solution to me.  Read the manual if you need more
information..
http://www.php.net/manual/en/function.explode.php
http://www.php.net/manual/en/function.date.php

- Kevin


- Original Message -
From: Sebastian [EMAIL PROTECTED]
To: Philip Hallstrom [EMAIL PROTECTED]
Cc: php list [EMAIL PROTECTED]
Sent: Wednesday, March 05, 2003 12:32 PM
Subject: Re: [PHP] Re: Date Question.


 can you give an example? I am stil learning :)

 - Original Message -
 From: Philip Hallstrom [EMAIL PROTECTED]


 | Strip off the H:i:s part using explode() and use date() to get an
 | equivalent string for right now and if they match, today's the day.
 |
 | On Wed, 5 Mar 2003, Sebastian wrote:
 |
 |  I have a date field in mysql in this format: Y-m-d H:i:s
 | 
 |  I would like to echo Today if the date is today, can someone offer
 some
 |  help? Thanks.


 --
 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] Re: Date Question.

2003-03-05 Thread Sebastian
Thank you very much, That worked well.

warm regards,
Sebastian.

- Original Message -
From: Kevin Stone [EMAIL PROTECTED]
To: Sebastian [EMAIL PROTECTED]; Philip Hallstrom
[EMAIL PROTECTED]
Cc: php list [EMAIL PROTECTED]
Sent: Wednesday, March 05, 2003 2:38 PM
Subject: Re: [PHP] Re: Date Question.


| He's recommending something like this..
|
| $tmp = explode(' ', $date);
| if (date(Y-m-d) == $tmp[0])  // date format -mm-dd
| {
| echo Today;
| }
|
| Seems like a reasonable solution to me.  Read the manual if you need more
| information..
| http://www.php.net/manual/en/function.explode.php
| http://www.php.net/manual/en/function.date.php
|
| - Kevin
|
|
| - Original Message -
| From: Sebastian [EMAIL PROTECTED]
| To: Philip Hallstrom [EMAIL PROTECTED]
| Cc: php list [EMAIL PROTECTED]
| Sent: Wednesday, March 05, 2003 12:32 PM
| Subject: Re: [PHP] Re: Date Question.
|
|
|  can you give an example? I am stil learning :)
| 
|  - Original Message -
|  From: Philip Hallstrom [EMAIL PROTECTED]
| 
| 
|  | Strip off the H:i:s part using explode() and use date() to get an
|  | equivalent string for right now and if they match, today's the day.
|  |
|  | On Wed, 5 Mar 2003, Sebastian wrote:
|  |
|  |  I have a date field in mysql in this format: Y-m-d H:i:s
|  | 
|  |  I would like to echo Today if the date is today, can someone offer
|  some
|  |  help? Thanks.


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



Re: [PHP] Re: date calculation

2003-02-16 Thread olinux
If you're using a database, it may be able to take
care of this for you. If you're using mysql:

6.3.4 Date and Time Functions
http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_functions

olinux 


--- Fred Merritt [EMAIL PROTECTED] wrote:
 Qt,
   The easiest way is to convert your dates into a
 serial day number(i.e. 
 the number of days that have elapsed between your
 date, and some 
 arbitrary date in the dim and distant past - I think
 PHP uses 25th 
 November, -4714).  There are some calendar functions
 in php that will do 
 this for you.  Once you have your dates as a numeric
 offset, you can 
 subtract them to get a the number of days between
 the dates, or you can 
 add or subtract a number of days to get a new
 offset.  Once you have the 
 new offset, there are reverse calendar functions in
 php, to convert your 
 new offset back to a calendar date.
 
 Check out the functions GregorianToJD(), and
 JDToGregorian(), in the 
 Calendar functions of the PHP manual.  If you do not
 have access to the 
 calendar functions in your version of php, there are
 also a couple of 
 examples how to do one of the conversions written in
 PHP, in the user 
 contributed notes of the manual.  There are also
 many published articles 
 describing algorithms on how to do this.  I can
 remember implementing 
 these functions in 1977(Not in PHP of course), from
 an article published 
 in the journal of the ACM, in 1963.
 
 Hope this helps. . . Fred
 
 Qt wrote:
  Dear Sirs,
  
  How can I add or subtract two date easily. Is
 therea any lib or function
  about this. I can not find any easy way in the
 manual
  
  Best Regards
  

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: [PHP] Re: date calculation

2003-02-16 Thread qt
No I am not using msql


Olinux [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 If you're using a database, it may be able to take
 care of this for you. If you're using mysql:

 6.3.4 Date and Time Functions

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

 olinux


 --- Fred Merritt [EMAIL PROTECTED] wrote:
  Qt,
  The easiest way is to convert your dates into a
  serial day number(i.e.
  the number of days that have elapsed between your
  date, and some
  arbitrary date in the dim and distant past - I think
  PHP uses 25th
  November, -4714).  There are some calendar functions
  in php that will do
  this for you.  Once you have your dates as a numeric
  offset, you can
  subtract them to get a the number of days between
  the dates, or you can
  add or subtract a number of days to get a new
  offset.  Once you have the
  new offset, there are reverse calendar functions in
  php, to convert your
  new offset back to a calendar date.
 
  Check out the functions GregorianToJD(), and
  JDToGregorian(), in the
  Calendar functions of the PHP manual.  If you do not
  have access to the
  calendar functions in your version of php, there are
  also a couple of
  examples how to do one of the conversions written in
  PHP, in the user
  contributed notes of the manual.  There are also
  many published articles
  describing algorithms on how to do this.  I can
  remember implementing
  these functions in 1977(Not in PHP of course), from
  an article published
  in the journal of the ACM, in 1963.
 
  Hope this helps. . . Fred
 
  Qt wrote:
   Dear Sirs,
  
   How can I add or subtract two date easily. Is
  therea any lib or function
   about this. I can not find any easy way in the
  manual
  
   Best Regards
  

 __
 Do you Yahoo!?
 Yahoo! Shopping - Send Flowers for Valentine's Day
 http://shopping.yahoo.com



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




Re: [PHP] Re: date question

2002-09-29 Thread Matt

 From: Jonas Geiregat [EMAIL PROTECTED]
 Sent: Sunday, September 29, 2002 10:56 AM
 Subject: [PHP] Re: date question


 and If I want to calculate from given date the next month
 like strtotime(next month) gives me the date of one month in advanced
 from NOW
 but I want to get the date one month in advanced from a given date not NOW

If you have mysql lying around, it has a bunch of date functions that can do
what you want:
http://www.mysql.com/doc/en/Date_and_time_functions.html



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




Re: [PHP] Re: Date() Problem

2002-07-27 Thread Justin French

I store all dates in unix timestamp format.  It's the easiest one to work
with, and it's easy to do things like date + three days, because it's just
a case of adding the right number of seconds to the current stamp.

You don't have to split anything, or get substr()'s of anything... and since
date() accepts unix timestamps AND is the easiest way to get date formats
(for me), I reckon it's the best way to go.


Justin


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




RE: [PHP] Re: Date() Problem

2002-07-27 Thread John Holmes

 I store all dates in unix timestamp format.  It's the easiest one to
work
 with, and it's easy to do things like date + three days, because
it's
 just
 a case of adding the right number of seconds to the current stamp.
 
 You don't have to split anything, or get substr()'s of anything... and
 since
 date() accepts unix timestamps AND is the easiest way to get date
formats
 (for me), I reckon it's the best way to go.

Well, I've got to butt in on this one and put in a big DISAGREE. Use
whatever is easiest for you, but MySQL provides a very rich assortment
of date and time manipulation functions that are a lot better than PHPs
(without any added classes). 

For example, to get everything from your database that was inserted
three days ago, you'd use:

SELECT * FROM your_table WHERE your_date_column = CURDATE() - INTERVAL 3
DAY;

Now, much of this is MySQL specific, though. I only use MySQL right now,
so it's not an issue, but it can be for some of you. 

Bottom line is use whatever is easiest for you, but realize that there
are a ton of Date and Time functions built into MySQL. Anything you can
do with a PHP function you can do with a MySQL function. You are also
not completely lost if you're storing things as Unixtimstamps. You can
convert from and to unixtimestamps and still make use of all of the
MySQL functions...

---John Holmes...


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




RE: [PHP] Re: date

2002-07-24 Thread John Holmes

   I am not sure it works, since isn't tested, but here we go. It's
pure
 Mysql, and it would be probaly easier, faster, and more readable to do
 with
 PHP mixed. But where's the fun of it? ;-)
 
 date_field is the name of your date column.
 
 $sql = SELECT IF(DAYOFMONTH(date_field) = DAYOFMONTH(CURRENT_DATE),
 'Today', IF (date_field = DATE_SUB(date_field, INTERVAL 1 DAYS),
 'Yesterday', date_field)) FROM table

I don't think you want DAYOFMONTH. Otherwise if today is July 24th, then
a date column with June 24th, or any 24th, will come up as Today.

Something like this will work, though...

SELECT IF(TO_DAYS(CURDATE()) =
TO_DAYS(date_column),'Today',IF(TO_DAYS(CURDATE())-1 =
TO_DAYS(date_column),'Yesterday',date_column)) FROM your_table;

Hope that helps...

---John Holmes...


 Julio Nobrega
 Pode acessar:
 http://www.inerciasensorial.com.br
 
 
 Alexander Ross [EMAIL PROTECTED] escreveu na mensagem
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I have a column in one of my mysql tables which holds the date 
time
 that
  the record was inserted.  When I run a query later on I want to
display
 the
  date, but if the date is today or yesterday I want to display
today or
  yesterday instead .. how do i compare to stored date with todays
date?
  todays date -1?  Thanks
 
 
 
 
 
 --
 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] Re: Date?

2002-06-09 Thread Jason Wong

On Sunday 09 June 2002 12:49, John Taylor-Johnston wrote:
 ? echo date (l., .F. .d., .Y); ?
 Sunday, June 09, 2002

 But I would use:

 ?php echo date (l., .F. .d., .Y); ?

or simply:

echo date (l F d, Y);

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

/*
Condense soup, not books!
*/


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




RE: [PHP] Re: Date?

2002-06-09 Thread Bruce Karstedt

? echo date(l, F j, Y); ? works just fine for me.

Bruce Karstedt
President
Technology Consulting Associates, Ltd.
Tel: 847-735-9488
Fax: 847-735-9474


-Original Message-
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 08, 2002 11:50 PM
To: [EMAIL PROTECTED]
Cc: Jeremy Bowen
Subject: [PHP] Re: Date?


? echo date (l., .F. .d., .Y); ?
Sunday, June 09, 2002

But I would use:

?php echo date (l., .F. .d., .Y); ?

Don't know why, but someone told me once it had something to do with
versions.

John

Jeremy Bowen wrote:

 I am having nothing but trouble with the date function. I want it to print
 out a date like this: Saturday June 8, 2002 but as soon as I put spaces or
 comma's in the string I get parse errors. I can get it to print
 SaturdayJune082002 with  ? echo date (lFdY); ? I have tried escaping
with
 \ but it seems to make no difference.



--
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] Re: Date?

2002-06-09 Thread Gerard Samuel

Speaking of which.  I was thinking about this this morning.
Is there a part of the Unix timestamp that tells php what timezone to 
report.
Reason why I ask, is I would like to offset the unix timestamp relative 
to where a server is to a particular user.
So lets say the user is in Europe, and the server is in USA and the 
script is set to display date as 'H:i T', and
I offset the unix timestamp to the user in Europe, would the timezone 
adjust to the European timezone...
Im going to try on a windows box where I can change the date easily and 
see what happens...

John Taylor-Johnston wrote:

I added a comment to the FAQ:
http://www.php.net/manual/en/function.date.php


  


-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/




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




Re: [PHP] Re: Date?

2002-06-09 Thread Miguel Cruz

On Sun, 9 Jun 2002, John Taylor-Johnston wrote:
 ? echo date (l., .F. .d., .Y); ?
 Sunday, June 09, 2002
 
 But I would use:
 
 ?php echo date (l., .F. .d., .Y); ?
 
 Don't know why, but someone told me once it had something to do with versions.

date() just wants a plain ordinary string for the first argument (as the
manual clearly says). I don't know what all that concatenation is for (I
guess with permissive parsing it will provide the same thing), but as the
examples in the manual also clearly show, you can just use:

   date ('l, F d, Y');

miguel


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




RE: [PHP] Re: Date?

2002-06-09 Thread David Freeman


  Speaking of which.  I was thinking about this this morning.
  Is there a part of the Unix timestamp that tells php what 
  timezone to 
  report.

You could use the gmt-based date manipulation to do this.

  Reason why I ask, is I would like to offset the unix 
  timestamp relative 
  to where a server is to a particular user.
  So lets say the user is in Europe, and the server is in USA and the 
  script is set to display date as 'H:i T', and

Your main problem will be in identifying where the user is.  Probably
the only truly reliable way is to ask them to tell you what their time
zone is.  Pretty much every other method will result in a percentage of
inaccurate reporting - the degree of error will be dependant on the
method chosen.

CYA, Dave



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




Re: [PHP] Re: Date?

2002-06-09 Thread Gerard Samuel

Ill look into gmdate.  I was going to get the timezone from the user to 
store in the database..

David Freeman wrote:

  Speaking of which.  I was thinking about this this morning.
  Is there a part of the Unix timestamp that tells php what 
  timezone to 
  report.

You could use the gmt-based date manipulation to do this.

  Reason why I ask, is I would like to offset the unix 
  timestamp relative 
  to where a server is to a particular user.
  So lets say the user is in Europe, and the server is in USA and the 
  script is set to display date as 'H:i T', and

Your main problem will be in identifying where the user is.  Probably
the only truly reliable way is to ask them to tell you what their time
zone is.  Pretty much every other method will result in a percentage of
inaccurate reporting - the degree of error will be dependant on the
method chosen.

CYA, Dave




  


-- 
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/




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




Re: [PHP] Re: Date?

2002-06-09 Thread Bogdan Stancescu

JavaScript's getTimezoneOffset seems to be working just right, as shown 
here: http://www.tyzo.com/tools/timezone.html

I think assuming that the user's computer has the correct time zone set 
shouldn't be too far-fetched - and you can always provide the user with 
a way to override that default.

Just my 2c.

Bogdan

David Freeman wrote:

  Speaking of which.  I was thinking about this this morning.
  Is there a part of the Unix timestamp that tells php what 
  timezone to 
  report.

You could use the gmt-based date manipulation to do this.

  Reason why I ask, is I would like to offset the unix 
  timestamp relative 
  to where a server is to a particular user.
  So lets say the user is in Europe, and the server is in USA and the 
  script is set to display date as 'H:i T', and

Your main problem will be in identifying where the user is.  Probably
the only truly reliable way is to ask them to tell you what their time
zone is.  Pretty much every other method will result in a percentage of
inaccurate reporting - the degree of error will be dependant on the
method chosen.

CYA, Dave



  






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




RE: [PHP] Re: date format

2002-04-27 Thread John Holmes

No...Do it in your query. Use DATE_FORMAT in your query.

---John Holmes...

 -Original Message-
 From: George Nicolae [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, April 27, 2002 12:43 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: date format
 
 try
 
 ?
 $date=2002-04-27;
 
 echo date(d-m-Y,strtotime($date));
 ?
 
 --
 
 
 Best regards,
 George Nicolae
 IT Manager
 ___
 PaginiWeb.com  - Professional Web Design
 www.PaginiWeb.com
 
 
 Ananth Rajaraman [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi all,
  I'm trying to query a date field from mySQL and
  display in a differnet format.
 
  the mysql date is in the format -MM-DD and I want
  to convert it to DD-MM-
 
  how do I do that?
 
  TIA
 
  Ananth
 
  =
  visit www.locustechnologies.com
 
  __
  Do You Yahoo!?
  Yahoo! Health - your guide to health and wellness
  http://health.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] Re: DATE Questions

2001-11-20 Thread Fred

Alright.  I was recently writting an attendance application for a school.  I
wanted to beable to display attendance information from mysql in a calendar,
but I did not want to have to write the calendar script from scratch.  I
must have looked at thirty or so calendar scripts before I found this one:
http://www.stevenrebello.f2s.com/ .  I chose this calendar because it looks
nice, but is very simple and does not contain a bunch of stuff I don't need.

I rewrote the script as a function and changed it to fit my needs.  I will
include the source here so that you can see how I made it work with mysql.
There are two places where I made changes.  First, you can see that I
changed the code for generating the links to last month and next month.  You
will need to do this in order to pass the correct variables to the page that
contains the function.

I then added the code for priting my dadabase information.  Most of the code
for formatting the data for each day is in a seperate function that gets
called once for each day on the calendar.  You will notice that I have the
database code in there twice.  This is because I did things a little
differently for the current day.  This is not necessary, but you will have
to rearrange the code a bit if you still want to highlight the current day.

Good Luck.
function  AttendanceCalendar($mon,$year,$Student,$Class)
{
  global $dates, $first_day, $start_day, $Attend;

  $first_day = mktime(0,0,0,$mon,1,$year);
  $start_day = date(w,$first_day);
  $res = getdate($first_day);
  $month_name = $res[month];
  $no_days_in_month = date(t,$first_day);

  file://If month's first day does not start with first Sunday, fill table
cell with a space
  for ($i = 1; $i = $start_day;$i++)
   $dates[1][$i] =  ;

  $row = 1;
  $col = $start_day+1;
  $num = 1;
  while($num=31)
   {
if ($num  $no_days_in_month)
  break;
else
 {
  $dates[$row][$col] = $num;
  if (($col + 1)  7)
   {
$row++;
$col = 1;
   }
  else
   $col++;
  $num++;
 }//if-else
   }//while
  $mon_num = date(n,$first_day);
  $temp_yr = $next_yr = $prev_yr = $year;

  $prev = $mon_num - 1;
  $next = $mon_num + 1;

  file://If January is currently displayed, month previous is December of
previous year
  if ($mon_num == 1)
   {
$prev_yr = $year - 1;
$prev = 12;
   }

  file://If December is currently displayed, month next is January of next
year
  if ($mon_num == 12)
   {
$next_yr = $year + 1;
$next = 1;
   }

  echo TABLE BORDER=\1\ WIDTH=\100%\ CELLSPACING=\0\
BORDERCOLOR=\cc\;

  echo  \nTR ALIGN='center'TD BGCOLOR='white' .
A
HREF=\$PHP_SELF?Module=StudentStudent=$StudentClass=$Classmonth=$prevye
ar=$prev_yr\ STYLE=\text-decoration: none\B/B/A /TD.
TD COLSPAN=5 BGCOLOR='cc'BFONT
Color='ff'.date(F,$first_day). .$temp_yr./B/FONT/TD.
TD BGCOLOR='white' .
A
HREF=\$PHP_SELF?Module=StudentStudent=$StudentClass=$Classmonth=$nextye
ar=$next_yr\ STYLE=\text-decoration: none\B/B/A /TD/TR;

  echo \nTR
ALIGN='center'TDBSun/B/TDTDBMon/B/TDTDBTue/B/TD;
  echo
TDBWed/B/TDTDBThu/B/TDTDBFri/B/TDTDBSat/B/TD
/TR;
  echo TRTD COLSPAN=7 /TRTR ALIGN='center';

  $end = ($start_day  4)? 6:5;
  for ($row=1;$row=$end;$row++)
   {
for ($col=1;$col=7;$col++)
 {
  if ($dates[$row][$col] == )
  $dates[$row][$col] =  ;

  if (!strcmp($dates[$row][$col], ))
   $count++;

  $t = $dates[$row][$col];

  file://If date is today, highlight it
  if (($t == date(j))  ($mon == date(n))  ($year == date(Y)))
  {
   file://echo \nTD BGCOLOR='cc'.$t./TD;
   echo \nTD bgcolor=\cc\;//.(($t ==   )? nbsp;
:$t)./TD;

   $Result = mysql_query(SELECT Attend, Credit, Date FROM Attendance
WHERE StudentID = \$Student\ AND SectionNo = \$Class\ AND MONTH(Date) =
\$mon\ AND YEAR(Date) = \$year\ AND DAYOFMONTH(Date) = \$t\,
MakeConn())
   or die (mysql_error());

   if (mysql_num_rows($Result)  0)
   {
   $DataRow = mysql_fetch_assoc($Result);
   extract ($DataRow);
   PrintDay($Attend,$Credit,$t,$mon,$year);
   mysql_free_result($Result);
   }

   echo /TD;}
  else {
  if ($t ==  ) {
  echo \nTD;
  echo /TD;
  }else{
   file://If the date is absent ie after 31, print space
   echo \nTD width=\60\ height=\60\;//.(($t ==   )? nbsp;
:$t)./TD;

   $Result = mysql_query(SELECT Attend, Credit, Date FROM Attendance
WHERE StudentID = \$Student\ AND SectionNo = \$Class\ AND MONTH(Date) =
\$mon\ AND YEAR(Date) = \$year\ AND DAYOFMONTH(Date) = \$t\,
MakeConn())
   or die (mysql_error());

   if (mysql_num_rows($Result)  0)
   {
   $DataRow = mysql_fetch_assoc($Result);
   extract ($DataRow);
   PrintDay($Attend,$Credit,$t,$mon,$year);
   mysql_free_result($Result);
   }
   else
   {
   echo $t;
   }



   echo /TD;}}
 }// for -col

if (($row + 1) != ($end+1))
 echo /TR\nTR 

RE: [PHP] Re: DATE Questions

2001-11-20 Thread Oosten, Sjoerd van

Fred thanks a lot, you really helped me out!


Sjoerd van Oosten 
Digitaal vormgever [EMAIL PROTECTED]
Datamex E-sites B.V. 
http://www.esites.nl
Minervum 7368 Telefoon: (076) 5 730 730 
4817 ZH BREDA Telefax: (076) 5 877 757 
___


-Oorspronkelijk bericht-
Van: Fred [mailto:[EMAIL PROTECTED]]
Verzonden: dinsdag 20 november 2001 18:18
Aan: [EMAIL PROTECTED]
Onderwerp: Re: [PHP] Re: DATE Questions


Alright.  I was recently writting an attendance application for a school.  I
wanted to beable to display attendance information from mysql in a calendar,
but I did not want to have to write the calendar script from scratch.  I
must have looked at thirty or so calendar scripts before I found this one:
http://www.stevenrebello.f2s.com/ .  I chose this calendar because it looks
nice, but is very simple and does not contain a bunch of stuff I don't need.

I rewrote the script as a function and changed it to fit my needs.  I will
include the source here so that you can see how I made it work with mysql.
There are two places where I made changes.  First, you can see that I
changed the code for generating the links to last month and next month.  You
will need to do this in order to pass the correct variables to the page that
contains the function.

I then added the code for priting my dadabase information.  Most of the code
for formatting the data for each day is in a seperate function that gets
called once for each day on the calendar.  You will notice that I have the
database code in there twice.  This is because I did things a little
differently for the current day.  This is not necessary, but you will have
to rearrange the code a bit if you still want to highlight the current day.

Good Luck.
function  AttendanceCalendar($mon,$year,$Student,$Class)
{
  global $dates, $first_day, $start_day, $Attend;

  $first_day = mktime(0,0,0,$mon,1,$year);
  $start_day = date(w,$first_day);
  $res = getdate($first_day);
  $month_name = $res[month];
  $no_days_in_month = date(t,$first_day);

  file://If month's first day does not start with first Sunday, fill table
cell with a space
  for ($i = 1; $i = $start_day;$i++)
   $dates[1][$i] =  ;

  $row = 1;
  $col = $start_day+1;
  $num = 1;
  while($num=31)
   {
if ($num  $no_days_in_month)
  break;
else
 {
  $dates[$row][$col] = $num;
  if (($col + 1)  7)
   {
$row++;
$col = 1;
   }
  else
   $col++;
  $num++;
 }//if-else
   }//while
  $mon_num = date(n,$first_day);
  $temp_yr = $next_yr = $prev_yr = $year;

  $prev = $mon_num - 1;
  $next = $mon_num + 1;

  file://If January is currently displayed, month previous is December of
previous year
  if ($mon_num == 1)
   {
$prev_yr = $year - 1;
$prev = 12;
   }

  file://If December is currently displayed, month next is January of next
year
  if ($mon_num == 12)
   {
$next_yr = $year + 1;
$next = 1;
   }

  echo TABLE BORDER=\1\ WIDTH=\100%\ CELLSPACING=\0\
BORDERCOLOR=\cc\;

  echo  \nTR ALIGN='center'TD BGCOLOR='white' .
A
HREF=\$PHP_SELF?Module=StudentStudent=$StudentClass=$Classmonth=$prevye
ar=$prev_yr\ STYLE=\text-decoration: none\B/B/A /TD.
TD COLSPAN=5 BGCOLOR='cc'BFONT
Color='ff'.date(F,$first_day). .$temp_yr./B/FONT/TD.
TD BGCOLOR='white' .
A
HREF=\$PHP_SELF?Module=StudentStudent=$StudentClass=$Classmonth=$nextye
ar=$next_yr\ STYLE=\text-decoration: none\B/B/A /TD/TR;

  echo \nTR
ALIGN='center'TDBSun/B/TDTDBMon/B/TDTDBTue/B/TD;
  echo
TDBWed/B/TDTDBThu/B/TDTDBFri/B/TDTDBSat/B/TD
/TR;
  echo TRTD COLSPAN=7 /TRTR ALIGN='center';

  $end = ($start_day  4)? 6:5;
  for ($row=1;$row=$end;$row++)
   {
for ($col=1;$col=7;$col++)
 {
  if ($dates[$row][$col] == )
  $dates[$row][$col] =  ;

  if (!strcmp($dates[$row][$col], ))
   $count++;

  $t = $dates[$row][$col];

  file://If date is today, highlight it
  if (($t == date(j))  ($mon == date(n))  ($year == date(Y)))
  {
   file://echo \nTD BGCOLOR='cc'.$t./TD;
   echo \nTD bgcolor=\cc\;//.(($t ==   )? nbsp;
:$t)./TD;

   $Result = mysql_query(SELECT Attend, Credit, Date FROM Attendance
WHERE StudentID = \$Student\ AND SectionNo = \$Class\ AND MONTH(Date) =
\$mon\ AND YEAR(Date) = \$year\ AND DAYOFMONTH(Date) = \$t\,
MakeConn())
   or die (mysql_error());

   if (mysql_num_rows($Result)  0)
   {
   $DataRow = mysql_fetch_assoc($Result);
   extract ($DataRow);
   PrintDay($Attend,$Credit,$t,$mon,$year);
   mysql_free_result($Result);
   }

   echo /TD;}
  else {
  if ($t ==  ) {
  echo \nTD;
  echo /TD;
  }else{
   file://If the date is absent ie after 31, print space
   echo \nTD width=\60\ height=\60\;//.(($t ==   )? nbsp;
:$t)./TD;

   $Result = mysql_query(SELECT Attend, Credit, Date FROM Attendance
WHERE StudentID = \$Student\ AND SectionNo = \$Class

Re: [PHP] Re: DATE Questions

2001-11-20 Thread Fred

Glad to help.  I'd be interested to know how it works out.

Fred

Sjoerd Van Oosten [EMAIL PROTECTED] wrote in message
C9F89DA57491D511BDAF00E0180C348103BFF1@ESADM01">news:C9F89DA57491D511BDAF00E0180C348103BFF1@ESADM01...
 Fred thanks a lot, you really helped me out!

 
 Sjoerd van Oosten
 Digitaal vormgever [EMAIL PROTECTED]
 Datamex E-sites B.V.
 http://www.esites.nl
 Minervum 7368 Telefoon: (076) 5 730 730
 4817 ZH BREDA Telefax: (076) 5 877 757
 ___


 -Oorspronkelijk bericht-
 Van: Fred [mailto:[EMAIL PROTECTED]]
 Verzonden: dinsdag 20 november 2001 18:18
 Aan: [EMAIL PROTECTED]
 Onderwerp: Re: [PHP] Re: DATE Questions


 Alright.  I was recently writting an attendance application for a school.
I
 wanted to beable to display attendance information from mysql in a
calendar,
 but I did not want to have to write the calendar script from scratch.  I
 must have looked at thirty or so calendar scripts before I found this one:
 http://www.stevenrebello.f2s.com/ .  I chose this calendar because it
looks
 nice, but is very simple and does not contain a bunch of stuff I don't
need.

 I rewrote the script as a function and changed it to fit my needs.  I will
 include the source here so that you can see how I made it work with mysql.
 There are two places where I made changes.  First, you can see that I
 changed the code for generating the links to last month and next month.
You
 will need to do this in order to pass the correct variables to the page
that
 contains the function.

 I then added the code for priting my dadabase information.  Most of the
code
 for formatting the data for each day is in a seperate function that gets
 called once for each day on the calendar.  You will notice that I have the
 database code in there twice.  This is because I did things a little
 differently for the current day.  This is not necessary, but you will have
 to rearrange the code a bit if you still want to highlight the current
day.

 Good Luck.
 function  AttendanceCalendar($mon,$year,$Student,$Class)
 {
   global $dates, $first_day, $start_day, $Attend;

   $first_day = mktime(0,0,0,$mon,1,$year);
   $start_day = date(w,$first_day);
   $res = getdate($first_day);
   $month_name = $res[month];
   $no_days_in_month = date(t,$first_day);

   file://If month's first day does not start with first Sunday, fill table
 cell with a space
   for ($i = 1; $i = $start_day;$i++)
$dates[1][$i] =  ;

   $row = 1;
   $col = $start_day+1;
   $num = 1;
   while($num=31)
{
 if ($num  $no_days_in_month)
   break;
 else
  {
   $dates[$row][$col] = $num;
   if (($col + 1)  7)
{
 $row++;
 $col = 1;
}
   else
$col++;
   $num++;
  }//if-else
}//while
   $mon_num = date(n,$first_day);
   $temp_yr = $next_yr = $prev_yr = $year;

   $prev = $mon_num - 1;
   $next = $mon_num + 1;

   file://If January is currently displayed, month previous is December of
 previous year
   if ($mon_num == 1)
{
 $prev_yr = $year - 1;
 $prev = 12;
}

   file://If December is currently displayed, month next is January of next
 year
   if ($mon_num == 12)
{
 $next_yr = $year + 1;
 $next = 1;
}

   echo TABLE BORDER=\1\ WIDTH=\100%\ CELLSPACING=\0\
 BORDERCOLOR=\cc\;

   echo  \nTR ALIGN='center'TD BGCOLOR='white' .
 A

HREF=\$PHP_SELF?Module=StudentStudent=$StudentClass=$Classmonth=$prevye
 ar=$prev_yr\ STYLE=\text-decoration: none\B/B/A /TD.
 TD COLSPAN=5 BGCOLOR='cc'BFONT
 Color='ff'.date(F,$first_day). .$temp_yr./B/FONT/TD.
 TD BGCOLOR='white' .
 A

HREF=\$PHP_SELF?Module=StudentStudent=$StudentClass=$Classmonth=$nextye
 ar=$next_yr\ STYLE=\text-decoration: none\B/B/A /TD/TR;

   echo \nTR
 ALIGN='center'TDBSun/B/TDTDBMon/B/TDTDBTue/B/TD;
   echo

TDBWed/B/TDTDBThu/B/TDTDBFri/B/TDTDBSat/B/TD
 /TR;
   echo TRTD COLSPAN=7 /TRTR ALIGN='center';

   $end = ($start_day  4)? 6:5;
   for ($row=1;$row=$end;$row++)
{
 for ($col=1;$col=7;$col++)
  {
   if ($dates[$row][$col] == )
   $dates[$row][$col] =  ;

   if (!strcmp($dates[$row][$col], ))
$count++;

   $t = $dates[$row][$col];

   file://If date is today, highlight it
   if (($t == date(j))  ($mon == date(n))  ($year ==
date(Y)))
   {
file://echo \nTD BGCOLOR='cc'.$t./TD;
echo \nTD bgcolor=\cc\;//.(($t ==   )? nbsp;
 :$t)./TD;

$Result = mysql_query(SELECT Attend, Credit, Date FROM Attendance
 WHERE StudentID = \$Student\ AND SectionNo = \$Class\ AND MONTH(Date)
=
 \$mon\ AND YEAR(Date) = \$year\ AND DAYOFMONTH(Date) = \$t\,
 MakeConn())
or die (mysql_error());

if (mysql_num_rows($Result)  0)
{
$DataRow = mysql_fetch_assoc($Result);
extract ($DataRow);
PrintDay($Attend,$Credit,$t,$mon,$year);
mysql_free_result($Result);
}


Re: [PHP] Re: DATE FORMAT ISSUES

2001-10-22 Thread Rasmus Lerdorf

Are you retrieving it using MySQL's UNIX_TIMESTAMP() function?  PHP's
date() function needs a unix timestamp to work with.

-Rasmus

On Mon, 22 Oct 2001, Beeman wrote:

 No it is definitely a DATETIME and the date and time are correct in the
 database, but when I try to format and display them the date is correct but
 the time is not
 _lallous [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  maybe you have in your database a DATE field instead of DATETIME field?
 
  Beeman [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   I have inserted the date into MySQL using now() in the query. However,
  when
   I retrieve the using MySQL_Date_Format in the query the time is always
   wrong. on the other hand, if I format the date using Date() in PHP it
  always
   makes the date DEC 31 1969 at 700PM. Please Help
  
  
 
 






-- 
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] Re: DATE FORMAT ISSUES

2001-10-22 Thread Beeman

Yeah, I select it using UNIX_TIMESTAMP(creation_datetime) and then I am
using date(M d, Y g:ia,$myrow[creation_datetime]) at the end of a printf
statement but the date comes back as Dec 31 1969 7:00pm for all entries.
When the date was inserted I used now() in the insert statement.
Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Are you retrieving it using MySQL's UNIX_TIMESTAMP() function?  PHP's
 date() function needs a unix timestamp to work with.

 -Rasmus

 On Mon, 22 Oct 2001, Beeman wrote:

  No it is definitely a DATETIME and the date and time are correct in the
  database, but when I try to format and display them the date is correct
but
  the time is not
  _lallous [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   maybe you have in your database a DATE field instead of DATETIME
field?
  
   Beeman [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
I have inserted the date into MySQL using now() in the query.
However,
   when
I retrieve the using MySQL_Date_Format in the query the time is
always
wrong. on the other hand, if I format the date using Date() in PHP
it
   always
makes the date DEC 31 1969 at 700PM. Please Help
   
   
  
  
 
 
 
 




-- 
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] Re: DATE FORMAT ISSUES

2001-10-22 Thread Rasmus Lerdorf

 Yeah, I select it using UNIX_TIMESTAMP(creation_datetime) and then I am
 using date(M d, Y g:ia,$myrow[creation_datetime]) at the end of a printf
 statement but the date comes back as Dec 31 1969 7:00pm for all entries.
 When the date was inserted I used now() in the insert statement.

You should be doing:

  select UNIX_TIMESTAMP(creation_datetime) as foo

  date(M d, Y g:ia,$myrow['foo'])

-Rasmus

 Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Are you retrieving it using MySQL's UNIX_TIMESTAMP() function?  PHP's
  date() function needs a unix timestamp to work with.
 
  -Rasmus
 
  On Mon, 22 Oct 2001, Beeman wrote:
 
   No it is definitely a DATETIME and the date and time are correct in the
   database, but when I try to format and display them the date is correct
 but
   the time is not
   _lallous [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
maybe you have in your database a DATE field instead of DATETIME
 field?
   
Beeman [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have inserted the date into MySQL using now() in the query.
 However,
when
 I retrieve the using MySQL_Date_Format in the query the time is
 always
 wrong. on the other hand, if I format the date using Date() in PHP
 it
always
 makes the date DEC 31 1969 at 700PM. Please Help


   
   
  
  
  
  
 






-- 
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] Re: DATE FORMAT ISSUES

2001-10-22 Thread Beeman

That worked. Thanks a lot... You rock
-Beeman
Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Yeah, I select it using UNIX_TIMESTAMP(creation_datetime) and then I am
  using date(M d, Y g:ia,$myrow[creation_datetime]) at the end of a
printf
  statement but the date comes back as Dec 31 1969 7:00pm for all entries.
  When the date was inserted I used now() in the insert statement.

 You should be doing:

   select UNIX_TIMESTAMP(creation_datetime) as foo

   date(M d, Y g:ia,$myrow['foo'])

 -Rasmus

  Rasmus Lerdorf [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Are you retrieving it using MySQL's UNIX_TIMESTAMP() function?  PHP's
   date() function needs a unix timestamp to work with.
  
   -Rasmus
  
   On Mon, 22 Oct 2001, Beeman wrote:
  
No it is definitely a DATETIME and the date and time are correct in
the
database, but when I try to format and display them the date is
correct
  but
the time is not
_lallous [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 maybe you have in your database a DATE field instead of DATETIME
  field?

 Beeman [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I have inserted the date into MySQL using now() in the query.
  However,
 when
  I retrieve the using MySQL_Date_Format in the query the time is
  always
  wrong. on the other hand, if I format the date using Date() in
PHP
  it
 always
  makes the date DEC 31 1969 at 700PM. Please Help
 
 


   
   
   
   
  
 
 
 
 




-- 
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] Re: Date/Time Query Help

2001-07-24 Thread Shrout, Ryan

Think of it this way:

WHERE session.Date  DATE_SUB(NOW(), INTERVAL 1 HOUR) is equal to:

WHERE 2001-07-24 15:03:24  SUBTRACTION( 2001-07-24 15:30:21, 00:01:00) =
WHERE 2001-07-24 15:03:24  2001-07-24 14:30:21 

That seems right now, but it doesn't work

Ryan

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 2:58 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Date/Time Query Help


On Tue, 24 Jul 2001 15:09:14 -0400, [EMAIL PROTECTED]
(Ryan Shrout) wrote:
I need a MySQL query that will select all the entries in it made within the
last hour.

I tried this, but it is not working correctly, what am I doing wrong?

SELECT * 
FROM session

WHERE (session.Date  DATE_SUB(NOW(), INTERVAL 1 HOUR))

Now() will return the current time.  by definition, at the time it's
running, there will be zero or almost zero (depends on how 
fast the query runs... someone might insert a row between
when the now() gets executed and when the query ends)
rows.  you are basically asking for rows that were inserted
from now up to one hour in the future.  those rows aren't
there yet.

try testing for less than.

-- 
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] Re: Date/Time Query Help

2001-07-24 Thread Bopolissimus Platypus

On Tue, 24 Jul 2001 15:23:10 -0400, [EMAIL PROTECTED]
(Ryan Shrout) wrote:

Think of it this way:

WHERE session.Date  DATE_SUB(NOW(), INTERVAL 1 HOUR) is equal to:

WHERE 2001-07-24 15:03:24  SUBTRACTION( 2001-07-24 15:30:21, 00:01:00) =
WHERE 2001-07-24 15:03:24  2001-07-24 14:30:21 

That seems right now, but it doesn't work

DATE_SUB.  heh.  that'll teach me not to read the whole
post and THINK about it :).


-- 
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] Re: Date/Time Query Help

2001-07-24 Thread Shrout, Ryan

Heh.  :)  

So, does anyone know what I am doing wrong?

Ryan Shrout

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 3:34 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Date/Time Query Help


On Tue, 24 Jul 2001 15:23:10 -0400, [EMAIL PROTECTED]
(Ryan Shrout) wrote:

Think of it this way:

WHERE session.Date  DATE_SUB(NOW(), INTERVAL 1 HOUR) is equal to:

WHERE 2001-07-24 15:03:24  SUBTRACTION( 2001-07-24 15:30:21, 00:01:00) =
WHERE 2001-07-24 15:03:24  2001-07-24 14:30:21 

That seems right now, but it doesn't work

DATE_SUB.  heh.  that'll teach me not to read the whole
post and THINK about it :).


-- 
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] Re: Date/Time Query Help

2001-07-24 Thread Bopolissimus Platypus

On Tue, 24 Jul 2001 15:23:10 -0400, [EMAIL PROTECTED]
(Ryan Shrout) wrote:

WHERE session.Date  DATE_SUB(NOW(), INTERVAL 1 HOUR) is equal to:

WHERE 2001-07-24 15:03:24  SUBTRACTION( 2001-07-24 15:30:21, 00:01:00) =
WHERE 2001-07-24 15:03:24  2001-07-24 14:30:21 

i just tested on my box (dialup connection logs, start is the datetime
the subscriber logged on) and when i do:

select login,start,end,secs from log where
  secs.startdate_sub(now(),interval 1 hour)

i get (it's after 3AM here... so the set is small):

+--+-+-+--+
| login| start   | end | secs |
+--+-+-+--+
| costales | 2001-07-25 02:52:35 | 2001-07-25 03:27:54 | 2119 |
| utopia   | 2001-07-25 03:19:38 | 2001-07-25 03:19:41 |3 |
+--+-+-+--+

works for me.  maybe it's a data problem? what version of 
mysql are you using?  what happens when you do:

select Date from session order by date desc limit 10;
?

tiger




-- 
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] Re: Date/Time Query Help

2001-07-24 Thread Shrout, Ryan

When I run: SELECT * FROM session WHERE session.Date  DATE_SUB(NOW(),
INTERVAL 1 HOUR)
I get an empty set, but there are entries that satisfy it.

When I run: select Date from session order by Date desc limit 10 
I get:
+-+
| Date|
+-+
| 2001-07-24 04:00:45 |
| 2001-07-24 04:00:40 |
| 2001-07-24 04:00:20 |
| 2001-07-24 03:22:24 |
| 2001-07-24 03:02:25 |
| 2001-07-24 02:53:55 |
| 2001-07-24 02:27:09 |
| 2001-07-24 02:24:54 |
+-+
8 rows in set (0.00 sec)



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 3:43 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Date/Time Query Help


On Tue, 24 Jul 2001 15:23:10 -0400, [EMAIL PROTECTED]
(Ryan Shrout) wrote:

WHERE session.Date  DATE_SUB(NOW(), INTERVAL 1 HOUR) is equal to:

WHERE 2001-07-24 15:03:24  SUBTRACTION( 2001-07-24 15:30:21, 00:01:00) =
WHERE 2001-07-24 15:03:24  2001-07-24 14:30:21 

i just tested on my box (dialup connection logs, start is the datetime
the subscriber logged on) and when i do:

select login,start,end,secs from log where
  secs.startdate_sub(now(),interval 1 hour)

i get (it's after 3AM here... so the set is small):

+--+-+-+--+
| login| start   | end | secs |
+--+-+-+--+
| costales | 2001-07-25 02:52:35 | 2001-07-25 03:27:54 | 2119 |
| utopia   | 2001-07-25 03:19:38 | 2001-07-25 03:19:41 |3 |
+--+-+-+--+

works for me.  maybe it's a data problem? what version of 
mysql are you using?  what happens when you do:

select Date from session order by date desc limit 10;
?

tiger




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