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 Complete Forum Thread with Replies
Related Forum 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 !
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 !
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 !
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 !
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 !
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 !
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 !
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 Replies !
Use The Strtotime Function To Converta Date
Im trying to use the strtotime function to convert this a date in this format ( 2007 11 11 20:34:56 ) to a unix timestamp. It should work (I think) but doesnt. What have I done wrong with the below code?? $date = strtotime($date); Thanks in advance. Eon201.
View Replies !
Problems With Strtotime()/date Comparison
I've a field in my database called CheckDate (type: date) in the format yyyy-mm-dd. I've 2 user inputs $start and $end in the format yyyy-mm-dd. I would like to check if the CheckDate is between the dates, $start and $end. Code:
View Replies !
Convert Date To A MySQL Acceptable Date
I've got a date that looks like this: 06/08/2007 AM I'm trying to convert it to a MySQL acceptable date so it can be inserted into the data and read as normal MySQL dates would read so I can use my date searching functions. I use a lot of -30 days searches and stuff like that. As I insert the records into the database (which come in from a .csv file) the "SCHEDULED_DATE" looks like that above but that, as we all know, won't work with things like 'SCHEDULED_DATE > $onemonth' ($onemonth being a date that is a month ago). So while the records are imported I have been trying to take that date and convert it into a usable MySQL date. Although my attempts have completely failed. Here is one of the newest things I have used, which didn't work and I really don't know why. Code:
View Replies !
Convert Input Date To Mysql Date
Wanted to see if there was a cleaner way to do this. My form takes a user-input date in the format MM/DD/YYYY. I need to convert that to YYYY-MM-DD to query against my database. The code below works, but basically I take input dates convert them to a UNIX timestamp with strtotime() and then convert them back to the format I need using strftime() PHP Code: $format = '%Y-%m-%d' $startDate =Â Â strtotime($startDate); $startDate = strftime($format, $startDate); $endDate =Â Â strtotime($endDate); $endDate = strftime($format, $endDate);
View Replies !
Convert The Date Separator Before Inserting The Date Into The DB
I need to convert the date separator before inserting the date into the DB. Right now, I have 01/01/2006 and I want 01-01-2006. The dates are coming from a CSV and so are an array element. I've tried strrpos and a few other functions trying to just replace the slashes with hypens and that's not working (I think maybe because it's an array and those functions don't work on arrays?) Could someone post example code for something like this? I have an array called $items[3] that holds the date with the separator mentioned above. I'm sure there are several ways to do it in both php and with mysql functions but I've been stuck on it for a while and REALLY need to get through this for a project I'm working on right now.
View Replies !
Unix Date Stamp Convert To UK Date
How do I go about converting the Unix date stamp to UK date/month/year. I know how to get the date from the database, I just need to know how I can convert this date using a php script to convert this to UK date format and display on my php page.
View Replies !
How To Convert Uk Date To Mysql Date Format
how to convert uk date to mysql date format? I have 3 textboxes having the values of dates. the format are the following: textbox1-29/08/2007 textbox2-14/08/2007 textbox3-20/08/2007 upon entering it into the database the following dates should be converted already to the mysql date format like 2007-08-29
View Replies !
Convert Date Into Day
I posted a question about session variables and appended variable value to a url and I figured it. Thanks for those who helped. Now, I have question about converting date into actual name of day. For example, converting 2005-05-12 to thursday. Is there a way to do that?
View Replies !
Convert Date In Php
is there a way to change the format of a date that is submitted through an html form? example: I have a form with a date field that accepts a standard U.S. date format of (%m/%d/%Y) but then when this: ($_POST['fdate'], "date") occurs I'd like it to take a date value of (%Y-%m-%d) so that the server will handle it.
View Replies !
Convert A Given Date
I need to convert a given date in this format (ex.2007-04-16) to the day of the year (ex.105). I know how to do this for todays date with the date() function. I need to compare todays day of the year (0-365) to a past date. I need to be able to mark 30 days past from a hire date to today's date.
View Replies !
Convert Date
Im trying to convert a date format of mm-dd-yyyy to yyyy-mm-dd. The latter is how it will be entered into the database. Heres the code: Code: $date = $_POST['sched_date']; $date = date('Y-m-d', strtotime($date)); For example, if date is 09-29-2007, it will format it to 09-29-2019.
View Replies !
How Can I Convert That Text To Date?
I'am trying to manipulate csv file using PHP, but my problem is that, one field there is date DD/DD/YYYY. My question is, how can I convert that text to date? So that I can insert it to the mysql database correctly.
View Replies !
Convert A Date Format
I am displaying records from a table including a stored date. When display $row[Date], i get the obvious 2006-05-21. However this is not what the guy wants. He wants 21-May-2006. I have tried several conversion functions but without success. I could do a long winded function, but i hoped there would be a simple solution.
View Replies !
Date Convert Function
i want to convert this : Fri Jul 25 14:33:21 2003 to seconds since 1970. so i use strtotime BUT-: strtotime ("Fri Jul 25 14:33:21 2003"); doesn't work i must put : strtotime ("Fri Jul 25 2003 14:33:21"); so from Fri Jul 25 14:33:21 2003 how to have Fri Jul 25 2003 14:33:21 i tried : date("D M j Y G:i:s", "Fri Jul 25 14:33:21 2003"); but it doesn't work.
View Replies !
Convert Date To Timestamp
Which one of the php functions will convert a date into a timestamp. I'm looking at the date/time functions on php.net, but they all seem to work the other way.
View Replies !
Convert Mysql Date
I am Using the following function to convert mysql date format into my req. function date_convert($date){ $date_year=substr($date,0,4); $date_month=substr($date,5,2); $date_day=substr($date,8,2); $date=date("F jS, Y", mktime(0,0,0,$date_month,$date_day,$date_year)); return $date; } echo date_convert($row['date']); //// $row['date'] is in the form :September 11, 2007.
View Replies !
Convert String To Date
I have string dates with the following format: mm/dd/yyyy I need to convert these to a date to evaluate them against the system time. I do not need a timestamp, just the day-date. Do I have to use the mktime function or is there a function that does not use time?
View Replies !
Convert Date Format On The Fly
Im rebuilding a website (a CMS). Ive been given the existing database which I now need to input into the new CMS. The dates (of the articles) are in this format "18/02/2006 16:32:57" Im used to working with dates in this format "20061802163257" (from this format its easy to order (the articles) by dates etc). How can I convert this date format (on the fly) to something more workable?
View Replies !
Convert Date Into A YYYY-MM-DD HH:MI Format
I want to convert a date...... I am given the Day of the Week, plus the Hour and Minute. I want to convert that into a YYYY-MM-DD HH:MI format so I can store it and sort it in the database. The only think I know is the beginning of the week date, and the end of the week date.......
View Replies !
Convert Date From A Database Query
I have a simple database for events. I have a column named "date" that I would like to display as "March 8, 2007" on the webpage. What do I need to add to change the date format? Here is my php code:
View Replies !
Convert Mysql Date Format
whats the best way to get a my mysql stored date in the format "2007-04-01" to output on screen with php help as April 2007. The day is not important, just the month and year in a readable fashion.
View Replies !
Convert From 1900 Date System
OMG, PHP has to have a simple function that converts an integer representing a date since 1900 to month, day, year. If so, I can't find it. I've got a CSV file from a spreadsheet that outputs the date as that integer value. All I want to do is read the file, convert that date integer to m,d,y and then display to a table on my site.
View Replies !
Convert The Start Date Into An Integer Of Seconds
The code below populates a calendar with a list of events for each day. Unfortunately the list of events appears under the correct day and year but repeat themselves for every month (i.e. an event on the 18th May also appears under 18th June, 18th July, 18th August... and so on. ) Each event has a start date and a duration (in days) so I convert the startdate into an integer of seconds, then add on the duration in seconds to find the enddate. I then list all events where the startdate <= calendar date and enddate >= calendar date. Code:
View Replies !
Convert Date String To Unix Time
Basically I wrote a little script that captured the date as a string like "July 3, 2007". Well, now I'd like to take all the information recorded and put it into another database as unix time (I'm wanting to migrate my personally written scripts into a more robust pre-written forum script). I think I need to use mktime(), but I'm not sure how to convert the string date above into something useable for mktime(). Any ideas?
View Replies !
Convert Numerics To Date For Comparison Purposes
OK so I MUST be being completely stupid but here's my problem. I have two separate variables that include numeric string referring to a date in UK format (ddmmyyyy) as follows: $traveldate = 05042007 $orderdate = 03032007 I need to perform an action if $orderdate is more than 3 days from $traveldate, i.e. this is an 'earlybird' reward. How the heck do I convert the string to a date and then compare the two to determine what action to take?
View Replies !
Convert Excel To Mysql Date Time
When i am tranfering the excel spread sheet data into Mysql through PHP by the method of excel COM object, I found that the date type of excel and mysql are not compatible. Excel using serial date (ie, how many days after 1900 Jan 0) and i can't convert this into mysql datetime. I want to convert the serial date in excel to Mysql Date Time, Is this possible through PHP and how.
View Replies !
Convert HTTP Header Last Modification Date To Integer
snoopy class can retrieve the specific page's lat modification date in String but is there any way to get into the integer or long? <?php include( "Snoopy.class.php" ); $request = new Snoopy; $request->fetch( "http://www.mysite.com" ); if( ! $request -error ){ while( list( $key, $val ) = each( $request -headers ) ) { echo $key.": ".$val."<br> "; } } ?>
View Replies !
Date_FORMAT Need To Convert Back To MySQL Date Format
Below is a couple of snippets of code that I have for modifying the date format from MySQL and it works great. The problem I am running into is later in the code I need to call the $AuctionDate variable to query the data field in another table. This won't work because the format has been modified using date_FORMAT. How do I convert it back to the MySQL date format so I can properly query the database. Code:
View Replies !
Convert Current Datetime Format To The Month And Date?
Right now, the following script pulls out the next three events from my SQL table and then displays them as: Datetime - Event Name (of course, with the appropriate information). Everything works GREAT on it, but she doesn't like the date format. She wants it to display the month and date only (i.e. July 22). How do I convert my current datetime format (normal mySQL datetime format) to the month and date? Code:
View Replies !
Date Function To Convert YYYY-MM-DD To More Elegant Format
I have a database table with several hundred records. The DB table has these fields: - id - name - date All the dates are in YYYY-MM-DD format. However, when they're displayed on my website, I want the dates to display like this: Jan 1, 2006 or Dec 12, 2006 (whatever the correct date is) Is there a function in PHP that I can use to convert YYYY-MM-DD to the more elegant format above?
View Replies !
Convert User Entered Date And Time To Unix Timestamp Before Inserting To Database
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard 0000-00-00 format of MYSQL so that I can do better calculations and queries.
View Replies !
Convert Query Results To Time Date/time Format
i have a query which displays the start time, end time, and also the duration. these results are displayed, however the duration doesnt seem to display in the correct format, it is displayed as numbers but not in the correct format. Code:
View Replies !
Convert Date() Month Numeric Into Month Full Name.
date("m"); returns the following result for this month... "02" That is fine and dandy, but the problem is, I need to change 02 into February, and not by changing it to date("F"); I need to use the date function to convert the supplied number of 02 into February, is there a way of going about this logically without a bunch of if/else statements??
View Replies !
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 !
|