473,379 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

PHP: DATETIME is Object?

Hello,

We're using PHP to query the Access DB and publish the data on the web.

Query the DB:

$qry = odbtp_query("SELECT end_date,title FROM projects ORDER BY
end_date DESC");

Get the query results:

while( ($rec = odbtp_fetch_array($qry)) ) {
echo "end_date is $rec[0], title is $rec[1]<br>";
}

The outputs are:

end_date is Object, title is 'blah blah'
end_date is Object, title is 'lajd;fsakf'
.....

'end_date' is of type DATETIME in Access. How DATETIME is actually
stored in Acces? Can anybody give me an example? Why PHP shows it as
Object? What should I do if I want end_date to be printed in the 'F j,
Y' format, like 'March 31, 2005'?

I'd appreciate any help.

Bing

Apr 13 '06 #1
6 2832
I'm not sure what library you're using to connect to the Access
database - I know I've done this before without problems, but not with
these odbtp functions.

One approach would be to use some of the built-in date format functions
right in your SQL query - something like:

SELECT FORMAT(end_date,'mmmm d, yyyy') AS date, title FROM projects
ORDER BY end_date DESC

Apr 13 '06 #2
"AllenWhite" <co******@allenwhite.net> wrote in
news:11**********************@t31g2000cwb.googlegr oups.com:
One approach would be to use some of the built-in date format
functions right in your SQL query - something like:

SELECT FORMAT(end_date,'mmmm d, yyyy') AS date, title FROM
projects ORDER BY end_date DESC


I don't think the Access Expression Service is available from ODBC,
so that won't work.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Apr 14 '06 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DateTime data types are stored as Double numbers in Access tables.
E.g.:

Now = 4/13/2006 6:25:50 PM and is stored as 38820.7679398148

The integer is the number of days since 12/30/1899 (the ZEROth day).
The decimal is the number of milliseconds since midnight of the
indicated date.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRD76t4echKqOuFEgEQL6VwCg/2C45yozmB2g8NKPFNH9Vh/0U8QAn2wC
Mdz56o0CTfNigL07XbJP/GsJ
=j8Hq
-----END PGP SIGNATURE-----
du****@gmail.com wrote:
Hello,

We're using PHP to query the Access DB and publish the data on the web.

Query the DB:

$qry = odbtp_query("SELECT end_date,title FROM projects ORDER BY
end_date DESC");

Get the query results:

while( ($rec = odbtp_fetch_array($qry)) ) {
echo "end_date is $rec[0], title is $rec[1]<br>";
}

The outputs are:

end_date is Object, title is 'blah blah'
end_date is Object, title is 'lajd;fsakf'
....

'end_date' is of type DATETIME in Access. How DATETIME is actually
stored in Acces? Can anybody give me an example? Why PHP shows it as
Object? What should I do if I want end_date to be printed in the 'F j,
Y' format, like 'March 31, 2005'?

I'd appreciate any help.

Bing

Apr 14 '06 #4
MGFoster <me@privacy.com> wrote in
news:VU*****************@newsread1.news.pas.earthl ink.net:
DateTime data types are stored as Double numbers in Access tables.
E.g.:

Now = 4/13/2006 6:25:50 PM and is stored as 38820.7679398148

The integer is the number of days since 12/30/1899 (the ZEROth
day). The decimal is the number of milliseconds since midnight of
the indicated date.


That is not true. The decimal part is the fraction of a day since
midnight of the day indicated by the integer part. If it were
actually milliseconds, it would be much easier, since there'd be no
rounding inaccuracies.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Apr 14 '06 #5
David W. Fenton wrote:
MGFoster <me@privacy.com> wrote in
news:VU*****************@newsread1.news.pas.earthl ink.net:

DateTime data types are stored as Double numbers in Access tables.
E.g.:

Now = 4/13/2006 6:25:50 PM and is stored as 38820.7679398148

The integer is the number of days since 12/30/1899 (the ZEROth
day). The decimal is the number of milliseconds since midnight of
the indicated date.

That is not true. The decimal part is the fraction of a day since
midnight of the day indicated by the integer part. If it were
actually milliseconds, it would be much easier, since there'd be no
rounding inaccuracies.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right you are. I must have been thinking of Unix time.

Therefore, the fraction .7679398148 means that almost 77 percent of the
day has passed.

Seconds in day = 86400

864000 * .7679398148 = 66349.99999872 seconds elapsed since midnight

(66349.99999872 / 60 ) / 60 = 18.4305555552 hours since midnight

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRD/NoYechKqOuFEgEQK21wCgqxAO8A5ujYmyepSCO77zOP+ST94Ao OD1
QCY40t8T07yKR2SJ9TQG+lXt
=vj+C
-----END PGP SIGNATURE-----
Apr 14 '06 #6
Bing,
How DATETIME is actually stored in Acces?
[...]
Why PHP shows it as Object?


Regardless of how Access stores datetime values internally, ODBTP
returns such values as a datetime object by default. You can change
this behaviour with an odbtp.datetime_format entry in PHP.INI...

http://odbtp.sourceforge.net/phpext.html#phpini

....or you can learn how to manipulate ODBTP's datetime object to get
the result you want.

IOW, this isn't really an Access question, it is an ODBTP question.

Apr 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andres Rosado-Sepulveda | last post by:
Hello, I'm having trouble compiling PHP 4.3.4 on Solaris 8. This is the error message it is showing: -- start -- Undefined first referenced symbol ...
34
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather...
5
by: I am Sam | last post by:
I have created this DateTime object and instanced it I think correctly DateTime myClubNow1=new...
8
by: Marcel | last post by:
I have a problem with a PHP page that seems to get executed twice. I am running PHP5 ISAPI on 2003 server. The script is a PHP page with a form. When the form is submitted one record have to...
6
by: Brandon | last post by:
I'm using PHP with MySQL 4.x and was having trouble converting a datetime from MySQL into a formatted string until I ran across this solution that converts a YYYY-MM-DD HH:MM:SS string into a...
7
by: jamesas | last post by:
I am wrote the coding for PHP 5 to access tourico holidays webservice. as follows.But it returns the error followed by the code .please help me <?php try{ class authentication_header {...
4
by: Michael Sharman | last post by:
Hi guys, I'm a little confused with dates. Ok, all I want to do is store a date in MySQL as a datetime object and be able to read and format it using PHP. My datatype in MySQL is DATETIME and...
3
by: Keith Hughitt | last post by:
Hi all, I was wondering if someone could help me out with a question about PHP Dates. I would like to pass a date to PHP via a query string, using ISO 8601 formatting ("2008-09-15T00:00:00Z"). I...
0
by: umalingesh | last post by:
Hi, I have a .Net webservice which takes a Datetime object as parameter public string GetDateTime(DateTime dt) { return dt.ToString(); }
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.