Strtotime Returning Funky Date
I'm sure there's a better way to code this, and pointers would be greatly appreciated, but my immediate problem is figuring out how to return the correct date. Upon retrieving $date1 from the database, I format it like so: PHP Code:
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Date Strtotime
i am trying to right a date into the mysql database but when i get the date from the html form and do strtotime on it it goes to an invalid date (by this i mean it is not the date i entered in the html form so for example 22-06-2007 changes to 28-11-2027).
View Replies !
View Related
Strtotime(date('m/d/Y'))
does the following code give the correct time:?strtotime(date('m/d/Y')) or do I need to use : strtotime(date('d/m/Y'))? I tried to find out which way the month and day work, but can't seem to find anything that will tell me.
View Replies !
View Related
Displaying A Date With Strtotime
I have successfully used strtotime to format the date on a webpage that is pulled form a MySQL database in the form yyyy-mm-dd. However, in another part of the webpage, I have to insert another date that may contain a NULL entry in the database. If I use strtotime to format this then it enters the current date, whereas I want it left blank.
View Replies !
View Related
Strtotime And A Very Mysterious Date
Namely the thirteenth of December 1901, 12:45:52, Pacific Time. All dates later than this passed in format "yyyy-mm-dd hh:mm:ss" to the strtotime function return the correct unix timestamp value (as can be verified by passing it back to date()). If a date earlier than 1901-12-13 12:45:52 is used, it returns an error. I tried this for a while to find the exact cut-off point, and this is it. Any reason - possibly a limitation of the integer value that is used? I didn't find this documented anywhere...
View Replies !
View Related
Use Strtotime To Convert A Date
I am trying to use strtotime to convert a date, gathered from a database, and add 21 days to the date. Example: Date from MySQL record is 2007-01-01 I need it to be echoed to the browser as 2007-01-22. Here is what I have now but it just outputs the database date without adding the 21 days. $requested = date('F jS, Y', strtotime($row['letter_requested'])); //Convert to letter requested date $sendBy = strtotime($requested, '+21 day'); echo $sendBy;
View Replies !
View Related
Strtotime And Date Functions
I'm trying to add 3 days to a stored starting date: echo $_SESSION['start_date']."<br>"; $new_timestamp = ($_SESSION['start_date'] + strtotime("+3 days")); $new_date = date('Y-m-d', $new_timestamp); echo $new_date; This ouputs: 2007-02-18 2007-02-25 (which is clearly + 7 days?) I would expect it to output: 2007-02-18 2007-02-21
View Replies !
View Related
More Date / Strtotime Confusion
I have an editable form, that (upon other things) retrieves a date from mysql. To prepopulate this text field, I use: $result = mysql_query("SELECT DATE_FORMAT(Expiration_Date, '%d-%b-%y') AS DateX FROM MyTable) or exit(mysql_error()); Which will return (for example): 01-Jan-06 I have a dropdown field that a user can use to select the number of days to add to this date. In addition, however, the user should also be allowed to opt to not use the dropdown, but type in the value instead, in the d-M-y format. Code:
View Replies !
View Related
Strtotime & Relative Date String
I thought something like this would work to get the next February after a specified date. $nextFebruary = strtotime( "next February", $unixDate ); However, if $unixDate corresponds to a date after February, I get the February before $unixDate instead of the February of the following year. I can, of course, check to see if $nextFebruary < $unixDate and, if it is, make sure I jump forward one year. But, I am thinking there is an easier way to accomplish this...as I cannot think of the method myself, I thought someone else might know.
View Replies !
View Related
Returning False On Date Function
I need to get someone's age in years + months for different dates. For some reason, my input check isn't working and I keep getting a mktime error? Is there an easier way to return false if dates aren't splitting or numeric? PHP Code: function getAge($date, $futureDate=false) { if(preg_match('/^[0-9]{2}/[0-9]{2}/[0-9]{4}$/', $date) === false) { return false; } elseif($futureDate!=false && preg_match('/^[0-9]{2}/[0-9]{2}/[0-9]{4}$/', $futureDate) === false) { return false; } $p = split('[/.-]', trim($date)); $start = mktime(0, 0, 0, $p[0], $p[1], $p[2]); $end = mktime(); // 1970s unix bday if($futureDate!==false) { $p = split('[/.-]', trim($futureDate)); // delimiter can be slash, dot, .........................................
View Replies !
View Related
Funky Popups.
I have:An index pageAn imageI want:A funky popup like the alt tag but heaps better.If you go here and click on one of the first three links you'll see what I mean. It's the windows help hints. I want something like it. I just thought PHP might have some funky popup code.
View Replies !
View Related
Funky Quotes
magic quotes are enabled on my server. I'm storing a blog into a database and when i use php to print it out i get question marks the like one below. What do i need to do? I've tried addslashes() but that didn't help at all. Is there something in between the database and php that i need to do? If i paste the text right into the db, it doesn't have the "[?]" thing code writing the text to db $blog = nl2br(trim($_POST['blog'])); $query = "INSERT INTO `blogs` (`team_id`, `title`, `blog`, `blogger_id`, `date_posted` ) VALUES ('$team_id', '$title', '$blog', '$blogger_id', '$timestamp');";
View Replies !
View Related
How To Deal With All Of Those MS Word Funky Characters
Put simply, I have a text box, and people commonly cut + paste information into this text box from Microsoft word. The problem is that word has all types of funky characters (smart quotes, em-dashes), that the system (php-based) doesn't understand. Does anyone know of a way to filter out these Microsoft-specific characters? Does PHP have a special function for this?
View Replies !
View Related
Returning NULL Vs. Returning FALSE
It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of?
View Replies !
View Related
Using Strtotime()
Lets say I have a variable $time = 'Apr 30 2007 7:00AM'. Is there a function that I can use or a way of using the strtotime function to see if that variable $time is between the hours of 7am and 7pm?
View Replies !
View Related
Strtotime
I am trying to compare 2 dates, so that if a post is older that 90 days the user is not allowed to edit it. i am storing the post date in mysql in datetime field (2007-04-21 10:53:07). My question is how to user strtotime function to compare the NOW() date&time with the stored one, so if greater that 90 days return true.
View Replies !
View Related
A Bug With Strtotime
Something seems to be wrong with the strtotime function in PHP5. I've created a staff resourcing database, which is used to assign staff to projects on a weekly basis. The database stores assignments against a week ending date, which is derived using: PHP Code: $week = date('Y-m-d',strtotime('Sunday')) This works fine, $week is set to the current week ending date (Sunday) using this. However, I also create $nextweek and $lastweek using: PHP Code: $nextweek = date('Y-m-d',strtotime('next sunday',strtotime($week))); $lastweek = date('Y-m-d',strtotime('last sunday',strtotime($week))); This has also been working fine, until we got to week ending Sunday 30th October. For some reason, when $week = 2005-10-30, $nextweek becomes 2005-10-05, which is a Saturday. I've tried replacing the 'next Sunday' with '+7 days', but this returns the same date. Is this a bug? Am I missing something?
View Replies !
View Related
Strtotime &
I've got a question and was hoping someone could offer some assistance. I've got this simple line in a test file. PHP Code: echo date("Y-m-d", strtotime("next Monday")); Here's my results using different versions of PHP:PHP 4.4.7: 2007-11-04PHP 5.1.2: 2007-11-05PHP 5.2.3: 2007-11-05 Todays date is November 03, 2007 (2007-11-03).
View Replies !
View Related
StrToTime () Issue
I'm using strtotime to get the timestamp for midnight. I have a statistics script for my pagecounter that displays hits since midnight. I also display the number of hours and minutes passed since midnight. $start = strtotime ('today 00:00'); $timepassed = date ('H:i', time () - $start); The weird part is at 11.30 AM it says 12 hrs and 30 minutes have passed. I tried adding GMT+1 like so: $start = strtotime ('today 00:00 GMT+1'); because I suspect the fact I'm in Holland is the reason for the miscalculation. But this format is refused by strtotime. (-1) Does anyone know a) whether this is indeed the problem, and b) how to fix it. Preferrably not alone for me here, but in suc a way anyone around the globe would have a correctly working script if they'd use mine. The php page for strtotime pointed me to a link at gnu.org where the syntax for it apparantly is listed, but I get a no such page error.
View Replies !
View Related
Strtotime And Cron
I've got a db of events which have dates attached to them which have been created using strtotime(). They don't have any time.. just the date. I've got a script which gets today's date using strtotime("today"). I use this as a comparison to find events which happen today. This works fine when I call the script from a URL, however when I called the php file from a cron job... the strtotime("today") creates values which are different each time. Are there any thoughts on what could be causing this? Firstly, I was wondering if the cron job was somehow using a different timezone to me (I'm On GMT). How do I explicitly tell php to use GMT.. .but then again.. this should matter too much, because I jsut want to date not the time! It also wouldn't account for the changing values of strtotime("today"). Just out of interest, does php4 and php5 handle strtotime("today") differently? I'm just wondering if cron is using the correct version of php?
View Replies !
View Related
Strtotime Question?
I have a string that looks like (a series of them) 1 Sep 2007 21:06:11 2 Sep 2007 13:45:31 2 Sep 2007 13:45:31 3 Sep 2007 01:40:42 and I want to go strto time on it any ideas its return -1 right now so I know somethings wrong.
View Replies !
View Related
Remove 0 From Strtotime?
Like every other blog in the world, I have mine displaying the date and time of each entry. Right now this is what I'm using: echo date('h:ia', strtotime($r[date])); My latest entry's time is displayed as 07:56pm. How do I remove the 0 when the hour is a single digit?
View Replies !
View Related
Strtotime() Pre-1970
if I code $birth = strtotime(Ƈ April 1950'); then $birth = -1, I guess that this is because time "began" on 1st Jan, 1970. (although I seem to remember a few good times before that). So, what's the easiest way to find out how many days old I am (exactly, please, not just taking 1 April 1970 and adding 20 *365, which does not account for leap years?
View Replies !
View Related
Strtotime Failure
I don't know how I should input date + time into a strtotime function (i'm a total noob) so I tested this: <? $d=01; $M=01; $y=1970; $h=01; $m=01; $s=01; echo "$d $M $y $h:$m:$s"; echo strtotime("$d $M $y $h:$m:$s"); ?> I get as echo strtotime '-1', wich means the strtotime has a failure. Can anybody explain me why? Or can anybody tell me how I can make a strtotime function that puts a timestamp in the database depending on the date and time inserted in a textbox? (one textbox or one textbox to insert the day, another to insert the year,...) I should be able to change a format like (for example) this : 01-02-1990 00:00:00 (midnight) into a timestamp. so dd-mm-yyyy hh:mm:ss (or something else just to make it work)I'm clueless.
View Replies !
View Related
Strtotime With Days
On this - "next Thursday" is that next thursday or the next thursday ie: on wed will it show tomorrows time or the next week? PHP Code: <?php echo strtotime("now"); $timestamp = strtotime("now"); echo "Â Â "; $str = date('l dS of F Y h:i:s A', $timestamp); echo $str; ?> <p> <?php echo strtotime("next Thursday"), ""; $timestamp = strtotime("next Thursday"); echo "Â Â "; $str = date('l dS of F Y h:i:s A', $timestamp); echo $str;
View Replies !
View Related
Strtotime Problem
How do I find the number of seconds from a certain date to the current? I have logged in my database a completion date within the past year and I want to figure out how many seconds it has been since the completion date until now. I know the strtotime command is fairly versatile and I have tried the following without the right conclusion: PHP Code: strtotime("since ".$completion_date); //and strtotime("from ".$completion_date); What do I need to do to fix this?
View Replies !
View Related
Strtotime Busted
$thing = "2005-10-01"; $storedDate = date("z",strtotime($thing)); echo $storedDate; it just alwats returns today's date, ive tried it on a php5 server and it worked fine however on the server I need this one it is PHP4.2.
View Replies !
View Related
Strtotime - Setting From Present
I am having trouble setting the strtotime function to echo 'Y-m-d' on any day from 1 - 24 months past. I have attempted the following from links that call to different ranges of dates; 6 months, 9 months, 12 months, etc. -- from present time: My SQL is set up as follows: WHERE Date between 'pastDATE' and CURDATE() pastDATE = $HTTP_GET_VARS["getDATE"] <a href="oldies.php?getDATE=<? echo strtotime ("-6 months ago"); ?>"> 6 MONTHS OLD </a> How can I echo the strtotime as "Y-m-d"?
View Replies !
View Related
Strange Strtotime() Behavior
I'm trying to use the strtotime() function to manage sessions. But I get the following <?php print(time() . " - " . strtotime("+1 hour")); ?> outputs: 1097380666 - 1097308800 Strange strtotime("+1 hour") produced a time stamp less than the current time. It also never changes. In other words strtotime("+1 hour") always results in the time stamp 1097308800. I have also tried strtotime("+1 hour", time()) with the same result Is this correct, have I misunderstood the strtotime() function? I'm running Gentoo with kernal 2.6.8.1, php 5.0.1, apache2
View Replies !
View Related
Comparing Dates With Strtotime()
I'm building a schedule script--well, modifying one I built last year--to add an event every second and third Sunday of the month. However, when I try to find that Sunday, and compare to my timestamp, I run into trouble: $myDays = getMyDays(); Code:
View Replies !
View Related
Difference Between Two Dates Using Strtotime
im having some problem regarding strtotime and date function.. i want to find the difference between two dates using strtotime.. and then use the difference in loop to determine the dates between the two given dates... but instead of year 2007.. the output year is 2001.. how come? here's my code:
View Replies !
View Related
Strtotime - Get The Dates Converted?
I inherited a website with an SQL database. I need to pull information from the database into Excel for future use but the date fields are in strtotime from what I can tell. (Example: 1149996306). Is there a formula I can plug into Excel that would allow me to convert these dates to actual dates I can use? Or is there a SQL script that I can insert in MySQL or Access to get the dates converted?
View Replies !
View Related
Strtotime Accepting Invalid Values
I'm using strtotime to validate a date/time passed in from a form but am having some problems with it. It seems to allow invalid values, such as "2004-04-13 21:66:13". Does anyone know why this is? Is this a bug or a "feature"? I'm using PHP 4.3.2.
View Replies !
View Related
Strtotime - Set To Work From A Different Time Zone
If you go there you will see that there are some color images and some grayed out versions of the images.. Now if you hover over the color image you will see that it has a time and date. what i want to do is if the time and date is before what it has on the hover over, for it to display the gray image.. if it is after the time and date on there for it to display the color image. Now i have that working ( i think ) with this if(strtotime('now') > strtotime($date $time)) { echo "<a href="#" target="_parent" title="$name is due on the $date at $time"> <img src="$image" />"; } else { echo "<img src='$image2'>"; But that uses unix time, and i need it set to work from a different time zone, does anyone know how i can change that to work from the time zone that i want.
View Replies !
View Related
|