Jump to content

Recommended Posts

Hey

 

I've done a few date comparisons before but nothing with this format so im kinda confused.

 

 

I have a field in my table which is "text" and the input format is mm/dd/yyyy .

 

Im trying to get php to mathematically return how many days passed from "now" on my server which using the dd/mm/yyyy.

 

How can this be done? If at all ?

 

Link to comment
https://forums.phpfreaks.com/topic/185652-php-date-comparisons/
Share on other sites

convert your table from text to date

use the format yyyy-mm-dd  ie for ex 2009-12-25

convert the string you want to compare 12/25/2008 to 2008-12-25 for example using explode

then after they are both in the same format you can use mysql comparisons in your query

for example

select * from table where date between '2008-12-25' and table.date

where table.date for example would be 2008-12-25

the big thing is set up you table correctly and have your dates properly formatted

 

after they are properly formatted you can also convert them to unix time() for ex $date1=time("2009-12-25"); $date2=time("2008-12-25"); then you would get a measurement in seconds which you could use in a slightly different way if you chose

Link to comment
https://forums.phpfreaks.com/topic/185652-php-date-comparisons/#findComment-980416
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.