RE: [PHP] [Q] Converting SQL Datetimes to timestamps

2004-08-03 Thread Vail, Warren
Try reversing the order in the date to -mm-dd and I believe it should
work.

Keep in mind that the time variable $ts is not the same as a Mysql timestamp
for example.  It conforms to the unix epoch time variable.

Warren Vail


-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Michael T. Peterson
Sent: Tuesday, August 03, 2004 11:05 AM
To: [EMAIL PROTECTED]
Subject: [PHP] [Q] Converting SQL Datetimes to timestamps


Evidently the strtotime() function will not convert an SQL datetime to a
timestamp. Am I missing something? Here's an example of what I mean:

$sql_datetime = '1948-30-03 01:30:00';
$ts = strtotime( $sql_datetime );
print( $ts.'br');

When this script is executed, strtotime() returns -1.

If true, that strtotime() is unable to convert SQL datetimes into
timestamps, how are others accomplishing this?

Cheers,

Michael

-- 
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] [Q] Converting SQL Datetimes to timestamps

2004-08-03 Thread Matthew Sims
 Evidently the strtotime() function will not convert an SQL datetime to a
 timestamp. Am I missing something? Here's an example of what I mean:

 $sql_datetime = '1948-30-03 01:30:00';
 $ts = strtotime( $sql_datetime );
 print( $ts.'br');

 When this script is executed, strtotime() returns -1.

 If true, that strtotime() is unable to convert SQL datetimes into
 timestamps, how are others accomplishing this?

 Cheers,

 Michael

From http://us4.php.net/manual/en/function.strtotime.php a user comments
about this:

 cryogen at mac dot com
06-Apr-2004 09:39
I neglected to include the solution in my last post for using strtotime()
with date-time data stored in GMT.  Append the string GMT to all of your
datetimes pulled from MySQL or other database that store date-times in the
format -mm-dd hh:ii:ss just prior to converting them to a unix
timestamp with strtotime().  This will ensure you get a valid GMT result
for times during daylight savings.

EXAMPLE:
?php
$date_time1 = strtotime(2004-04-04 02:00:00); // returns bad value -1
due to DST
$date_time2 = strtotime(2004-04-04 02:00:00 GMT); // works great!
?


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

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



Re: [PHP] [Q] Converting SQL Datetimes to timestamps

2004-08-03 Thread Jason Wong
On Wednesday 04 August 2004 02:05, Michael T. Peterson wrote:
 Evidently the strtotime() function will not convert an SQL datetime to a
 timestamp. Am I missing something? Here's an example of what I mean:

 $sql_datetime = '1948-30-03 01:30:00';
 $ts = strtotime( $sql_datetime );
 print( $ts.'br');

 When this script is executed, strtotime() returns -1.

 If true, that strtotime() is unable to convert SQL datetimes into
 timestamps, 

No it's not true, RTFM. 

 how are others accomplishing this?

If you're need to process a wider range of dates use the Julian day functions

  manual  Calendar Functions

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
It takes two to tell the truth: one to speak and one to hear.
*/

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



Re: [PHP] [Q] Converting SQL Datetimes to timestamps

2004-08-03 Thread John Holmes
Michael T. Peterson wrote:
Evidently the strtotime() function will not convert an SQL datetime to a
timestamp. Am I missing something? Here's an example of what I mean:
$sql_datetime = '1948-30-03 01:30:00';
$ts = strtotime( $sql_datetime );
print( $ts.'br');
When this script is executed, strtotime() returns -1.
If true, that strtotime() is unable to convert SQL datetimes into
timestamps, how are others accomplishing this?
strtotime() will work, actually, but not for dates before 1970. If you 
want to convert a database timestamp to a Unix timestamp that's before 
1970, you need to be on an OS that supports negative timestamps (not 
windows, as far as I know).

--
John Holmes
php|architect - The magazine for PHP professionals - http://www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] [Q] Converting SQL Datetimes to timestamps

2004-08-03 Thread John Nichel
On Tuesday 03 August 2004 14:05, Michael T. Peterson offered up the 
following tid-bit of information :
 Evidently the strtotime() function will not convert an SQL datetime to a
 timestamp. Am I missing something? Here's an example of what I mean:

 $sql_datetime = '1948-30-03 01:30:00';
 $ts = strtotime( $sql_datetime );
 print( $ts.'br');

 When this script is executed, strtotime() returns -1.

 If true, that strtotime() is unable to convert SQL datetimes into
 timestamps, how are others accomplishing this?

 Cheers,

 Michael

It works with SQL datestampsjust not with that one above.  The year 
(1948) will return a negative timestamp

quote from http://us4.php.net/strtotime
Note:  The valid range of a timestamp is typically from Fri, 13 Dec 1901 
20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that 
correspond to the minimum and maximum values for a 32-bit signed integer.) 
Additionally, not all platforms support negative timestamps, therefore your 
date range may be limited to no earlier than the Unix epoch. This means 
that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux 
distributions, and a few other operating systems.
/quote

-- 
John C. Nichel
berGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



RE: [PHP] [Q] Converting SQL Datetimes to timestamps

2004-08-03 Thread Ed Lazor
Check out strtotime in the PHP manual.  It gives a few examples of how to
use the function that I think will answer your first question.  Next, check
out mktime, time, and date.

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of Michael T. Peterson
 Sent: Tuesday, August 03, 2004 11:05 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] [Q] Converting SQL Datetimes to timestamps
 
 Evidently the strtotime() function will not convert an SQL datetime to a
 timestamp. Am I missing something? Here's an example of what I mean:
 
 $sql_datetime = '1948-30-03 01:30:00';
 $ts = strtotime( $sql_datetime );
 print( $ts.'br');
 
 When this script is executed, strtotime() returns -1.
 
 If true, that strtotime() is unable to convert SQL datetimes into
 timestamps, how are others accomplishing this?
 
 Cheers,
 
 Michael
 
 --
 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