Jump to content

Recommended Posts

I'm trying to compare a Deadline with current Date.  it's returning -1 for Deadline.  do i have the right syntax? 

the HTML form is Month, Day, Year, Hour, PM

ex:  2 16 2008 11 PM

 

$Deadline = date("U", strtotime(" ".$PickDeadline_Month." ".$PickDeadline_Day." ".$PickDeadline_Year." ".$PickDeadline_Hour." ".$PickDeadline_PM." "));

$Today = date("U");  

echo "<br>Deadline = ".$Deadline."";
echo "<br>Today = ".$Today."";

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

In order for strtotime to return a unix timestamp it requires a valid english readable date, eg:

2/16/2008 23:00 not 2 16 2008 11 PM

 

You might want to look into mktime rather than strtotime. Also no need to use date either to convert the value strtotime returns as it already returns a unixtime stamp. Another thing which is not required (and irritates me - no offense) is ending lines with empty strings after/before using a variable (."");

 

 

Link to comment
https://forums.phpfreaks.com/topic/91562-strtotime-syntax/#findComment-469001
Share on other sites

Another thing which is not required (and irritates me - no offense) is ending lines with empty strings after/before using a variable (."");

 

 

 

Agreed. I often see people doing it though. Is there a book out there where the author advocates such usage?

Link to comment
https://forums.phpfreaks.com/topic/91562-strtotime-syntax/#findComment-469007
Share on other sites

try '2008-02-16 11 PM'

 

I need to use those variable names because the admin will be changing the Deadline to whatever they want.  can someone change the code to what it should be if I was just using variable names?  I'm still trying to understand this whole strtotime and date.  as for the empty strings """ before/after I think it's just cuz i'm used to using echo "test = ".$var.""; 

 

Link to comment
https://forums.phpfreaks.com/topic/91562-strtotime-syntax/#findComment-469010
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.