Regarding date and time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mabus
Forum Newbie
Posts: 17
Joined: Wed Apr 16, 2008 11:52 pm

Regarding date and time

Post by mabus »

Hello,

I am looking for some tutorials on how to calculate date / time on php, that utilizes the date object.

For a while, I have been using date(), and strtotime() to come up with dates, but doing calculation and comparing the outputs from those means string comparisson, which is not what I want.

Can you point out some tutorials or links where I can get some samples on using date object ot be able to calculate or comapre dates?

thanks in advance
Mr.RED
Forum Newbie
Posts: 8
Joined: Sat May 31, 2008 1:23 pm

Re: Regarding date and time

Post by Mr.RED »

Hard to tell what you mean but have been using dates in the format of "DD-MM-YYYY" for example? Try using timestamps instead which makes it much easier to compare dates.
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Regarding date and time

Post by nowaydown1 »

Zend Framework has a Date object:

http://framework.zend.com/manual/en/zend.date.html
mabus
Forum Newbie
Posts: 17
Joined: Wed Apr 16, 2008 11:52 pm

Re: Regarding date and time

Post by mabus »

Mr.RED wrote:Hard to tell what you mean but have been using dates in the format of "DD-MM-YYYY" for example? Try using timestamps instead which makes it much easier to compare dates.
hhmm.. this is actually what I considered as my last resort. I don't know if there are any other ways besides time stamps, but I'm open to this idea . Well, what I meant was , I'm using the date() method of php to be able to compu with dates that I compare. Now, since date() returns a string, then that means that the comparing is basically string comparison. What I want to get, is a comparison of dates, as if they are really date variables or date objects.
nowaydown1 wrote:Zend Framework has a Date object:
http://framework.zend.com/manual/en/zend.date.html
hhhmm.. are they using the native php date object, or do they have a library of some sort that has dates? I am current using another framework right now. I'm not sure if I wanna transfer it to zend.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Regarding date and time

Post by califdon »

There's really a world of information available on date comparisons. Like http://www.phpf1.com/tutorial/php-date-compare.html

Try Googling it.
Post Reply