Jump to content

Recommended Posts

I have a php dilemma here.

 

I have a string to time function dilemma here (that I didnt notice would happen), I have a really big search facility here, that we have had our first customer order on.

 

At the moment, you say search on one date like so:

 

From :15th of feb 2010

To: 15th of feb 2010

 

Would bring up the same time wouldnt it, missing the results in effect.

 

How would one go from midnight on the 'From' part (ie 00:00), to right at the end of the day on the To date (23:59)?

 

This would be using some form of offset wouldnt it, how would I achieve this please?

 

Any help is greatly appreciated, thanks.

 

Jeremy.

Link to comment
https://forums.phpfreaks.com/topic/192146-strtotime-problem/
Share on other sites

strtotime() will only work properly on US English date formats, for example 15 January 2009 08:41:03.

 

So you will have to expand the month to its full name, so instead of feb it will need to be February. You'll also need to loose the ordinal suffix (st, nd, rd or th) too from your original dates. With your dates now in the format strtotime expects you can do this

 

$fromDate = '15 February 2010 05:00:00';

$toDate = date('j F Y H:i:s', strtotime('+23 hours 59 minutes', strtotime($fromDate)));

echo "$fromDate to $toDate";

Link to comment
https://forums.phpfreaks.com/topic/192146-strtotime-problem/#findComment-1012710
Share on other sites

  • 3 weeks later...

Sorry to be a pain with this lol.

 

But I am having real problems in getting the output I want from your example.

 

At the moment, I have cleared out my code and gone from whats been generating from my search form, this is as below:

03 5 2010

 

Thats the same format for the from and to date yea?

 

How would I go from saying with that value, getting it to use the date from the start say 00:00 am to 23:59:59 at night? Of course being afternoon.

 

If I say it was the $fromdate and then the $todate those values where echoing out as as it where, how would I go from that whole echo to coming out with the equivalent time stamp sorry?

 

If you could give me some more help I would greatly appreciate it!

 

Regards,

Jeremy.

Link to comment
https://forums.phpfreaks.com/topic/192146-strtotime-problem/#findComment-1021890
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.