Jump to content

strtotime syntax


chiefrokka

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.