PHP - Datetime In Excel Csv Field
Hi, basically i am parsing some rtf/word files and generating excel csv's for upload into mysql database....my issue is in one of the fields i want to store the value in the mysql datetime / date format but excel keeps reformating it. Any help on how to overcome this will be highly appreciated.
Similar TutorialsI am trying to import into a csv file and filter the results to a particular user and only results based on the time the data was uploaded within one hour. In other words anything not uploaded within the last hour of the start_time will not appear in the csv file. Everything works fine except for the time part. I get no results at all with the 'and unix_timestamp........ For all I know possibly I am way off with my effort. The field name is start_time. Here is code below. Appreciate any help.
<code> header('Content-type: application/csv'); </code> Hello, I am trying create a news article, but I have few category in it. Can you help me to create an "add article form" which has dropdown list of category that I can choose, so when I select "Announcement" it will save the data on my mysql database under announcement table. sample html form below. <form id="form1" name="form1" method="post" action=""> <label> Category : <select name="category" id="category"> <option>--- choose category ---</option> <option>News</option> <option>Announcement</option> <option>Sports</option> </select> </label> <br /> Date: <br /> Title: <label> <input type="text" name="title" id="title" /> </label> <br /> Body: <label> <textarea name="body" id="body" cols="45" rows="5"></textarea> </label> <br /> <label> <input type="submit" name="Submit" id="Submit" value="Submit" /> </label> <br /> <br /> </form> Can you tell me how to create the php code which support the above html. Also, I would like to have a date and time on my article, but I want it automatically get the time and date from the computer of the client, so the user will not put it manually. can you point me to the correct code? Thanks and hope you can help me! Dear all, how can I convert a string "yyyy-mm-dd hh:mm" into a really datetime value with php? thanks! I need some help and hopefully will respond. I'm trying to put some information to the second row of the excel sheet once extracted. Can somebody help me with this script? I'm trying to move the address line to the second row. Thanks. Hello, i am currently getting an Microsoft Excel formatted text file whose save type is .Txt from a URL.I used to open it and will change the save type as excel file. Please suggest whether we can do this with php code. currently my code is like this, <? php copy("http://www.faa.gov/airports/airport_safety/airportdata_5010/menu/emergencyplanexport.cfm?Region=&District=&State=&County=&City=LAS%20VEGAS&Use=&Certification=","./contactsexport.xls"); ?> where as the contactsexport.xls type is .Txt which i need it in .xls Thanks in Advance. Hello All, I have the following code: Code: [Select] echo "<table width='615px' cellpadding='3' cellspacing='4' align='center'>"; echo "<tr>"; echo "<td align='left' width='150px'>"; echo substr($row['date'],0,11); echo "</td>"; echo "<td align='left' width='465px'>"; echo $row["food"] ; echo "</td>"; echo "</tr>"; echo "</table>"; And this outputs: Apr 4 2011 Chicken Ceasar Salad, Garlic Toast, Cloddhoppers, Applesauce, & Milk (etc.) How can I add "Mon" in front of "Apr 4 2011"? thanks! This code gives me 1969-12-31 18:33:30 Code: [Select] <?=date('d M Y', $val['Created']);?> and this one gives me 2010-11-04 03:52:54 WHICH IS THE RIGHT ONE - BUT i need to format as above. Code: [Select] <?=$val['Created']?> this happens on the same line of code. What is wrong? Code: [Select] OFXAdapter: Failed to parse request: Unable to parse an atomic field "OFXRequest.OFXRequest.SignOnMsgsRqUn.SignOnMsgsRqV1.SonRq.DtClient": field value "20101005091544.000[-4:EDT]" is not a valid (YYYYMMDDHHMMSS.XXX[gmt offset:tz name]) date. I am trying to put together some PHP code to use the OFX standard to communicate with my bank in order to download my recent transactions. The standard details that in the sign-on request, the date and time must be included in the format listed above. As you can see, I have the value in the exact same format as specified. So my question is this: is there something about GMT offset or TZ names that I am missing here? Hi Everyone, Please have a look at this, and tell me if its right? I am generating a sitemap for my website dynamically. The date I am providing: 2012-02-24 11:56:09 and this is the output I am getting: 2012-02-24T11:56:09Z now I am not sure of the Z at the end of the returned value. I think I am looking for something similar to this: 2012-03-12T12:00:02+02:00 not to sure what I am doing wrong and where it gets the timezone from, I am guessing from the php config file. any help would be much appreciated. thanks My code: Code: [Select] <lastmod><?php echo $time->toAtom($post['Post']['modified']); ?></lastmod> Hey, does anybody know a good function, where I can have the trendy "time ago" functionality?
A good tutorial would be cool, too.
I would be using the datetime function off MySQL.
Hi, I'm a newbie here, and with PHP, and need some help with the datetime display. I am wanting to utilize old Naval comms DTG (datetimegroup) format which is DDHHMM 3-digit Month 2-digit year. The DDHHMM = Day (01 - 31) HH (hour 01 - 24) MM (minute 00 - 59) What I need to do is to add the letter Z (meaning GMT, ZULU) like thus DDHHMMZ FEB 11 How can I go about inserting that Z into this? Tks in advance for any assist Hello!! i want to save datetimes into a mysql database. Their format is dd-mm-yy hh:mm. I think mysql format for datetime is yy-mm-dd hh:mm..How can i convert them?? Basically I am using DATETIME to store the time in which a row was input. Format - 2010-11-13 21:31:53 How would I get the current time of page load and compare it to the database row "2010-11-13 21:31:53" then output the difference. Example $sqlresult = 2010-11-13 21:31:53; $currentTime = (GET CURRENT DATE+TIME = (2010-11-13 21:31:55) ); Output - This was posted 2 minute's ago. Thank you in advance. Any help would be greatly appreciated. I'm given something like this: Sun Nov 06 2011 09:30:00 GMT-0500 (EST) And i'm trying to turn that into 2011-11-06 09:30:00 I started by using explode and trying to loop through the day and month to figure it out, but that seems inefficient and overly complicated. Am i missing something? Thanks Hi all, I am currently storing dates and times for certain events in the following format: $now= date('Y-m-d H:i:s'); This variable is then stored in a MySQL field of type DATETIME. I am looking for a way to query the database to return all results in a certain month, or within a certain time range, or a certain year etc. How would this be achieved? e.g. If I wanted to select everything for the year 2009, would it be: SELECT * FROM table WHERE date BETWEEN '2009-01-01 00:00:00' AND '2009-12-31 11:59:59' ? Thanks! Hello, I have a query that displays a list of events for the year, and am in need of guidance on how to have it only show events that are >= today's date. The 'date' is inserted into the table as a varchar field from javascript code. There was an old blog post about doing something like.... Code: [Select] SELECT * FROM calendar WHERE `date` >= NOW() ORDER BY date ASC LIMIT 5 I seem to have trouble in that i believe NOW() will only work with proper datetime entries as opposed to my varchar setup. any help navigating this would be great. Hi, so I am trying to get how many minutes and seconds are left from the datetime entry in the database and the current datetime, but I'm having issues... Here's my code: Code: [Select] $query = "SELECT RequestMadeDateTime FROM TempAwaitingClients WHERE PSOID = '2'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $RequestMadeDateTime = $row['RequestMadeDateTime']; $currentDateTime = date('Y-m-d H:i:s'); echo 'Request Made Date Time: ' . $RequestMadeDateTime . '<br />'; echo 'Current Date Time: ' . $currentDateTime . '<br />'; echo date_diff($RequestMadeDateTime, $currentDateTime); What I'm getting those is this, "Warning: date_diff() expects parameter 1 to be DateTime" ... Which I don't get because both variables are DateTime... I have a page where "Events" which may be of interest to site visitors can be recorded. Among other info, an "Event" has a "from" date and a "to" date (to show that an event will run from October 29th to October 31st, for example). All event info is being written to the db, but the "from" and "to" dates are not. (In the db, "0000-00-00 00:00:00" is being entered in the "from" and "to" columns.) In the Events table, both event_date and event_end_date are of type datetime. Dates are entered into the form fields via a javascript datepicker and are in the format "24/09/2011". I'm using this code: Code: [Select] // Check for a Start Date: if (empty($_POST['from'])) { $errors[] = 'You forgot to enter a Start Date for the event.'; } else { $from = $_POST['from']; } // Check for an End Date: if (empty($_POST['to'])) { $errors[] = 'You forgot to enter an End Date for the event.'; } else { $to = $_POST['to']; } The db query is this: Code: [Select] if (empty($errors)) { // If everything's OK. // Insert the Event info in the database... // Make the query: $q = "INSERT INTO events (title, event_date, event_end_date, venue, ext_link, blurb) VALUES ('$title', '$from', '$to', '$venue', '$ext_link', '$blurb') "; $r = @mysqli_query ($dbc, $q); // Run the query. if ($r) { // If it ran OK. // Print a message: echo "<h2>Event info added!</h2> <h3>Your entry is now visible on the <a href='index.php'>Home Page</a>.</h3> <p><a href='logout.php'><strong>Log out</strong></a></p> " ; mysqli_close($dbc); include('inc/footer.php'); exit(); And the form is this: Code: [Select] <form id="form1" name="form1" method="post" action="add_event.php"> <label for="title">Title</label> <input type="text" name="title" id="title" value="<?php if (isset($_POST['title'])) echo $_POST['title']; ?>" /> <script> $(function() { var dates = $( "#from, #to" ).datepicker({ defaultDate: "", changeMonth: true, numberOfMonths: 1, onSelect: function( selectedDate ) { var option = this.id == "from" ? "minDate" : "maxDate", instance = $( this ).data( "datepicker" ), date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings ); dates.not( this ).datepicker( "option", option, date ); } }); }); </script> <label for="from" >*From</label> <input type="text" name="from" id="from" value="<?php if (isset($_POST['from'])) echo $_POST['from']; ?>" /> <label for="to" ">*To</label> <input type="text" name="to" id="to" value="<?php if (isset($_POST['to'])) echo $_POST['to']; ?>" /> <label for="venue">*Venue</label> <input type="text" name="venue" id="venue" value="<?php if (isset($_POST['venue'])) echo $_POST['venue']; ?>" /> <label for="blurb">*Description</label> <textarea name="blurb" id="blurb" value="<?php if (isset($_POST['blurb'])) echo $_POST['blurb']; ?>" rows="5" ></textarea> <label for="ext_link">External link (optional, entered like "www.example.com")</label> <input type="text" name="ext_link" id="ext_link" value="<?php if (isset($_POST['ext_link'])) echo $_POST['ext_link']; ?>" /> <input type="submit" name="submit" value="Insert Event Info" class="submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> Can anyone tell me why the dates aren't being recorded? Any help will be greatly appreciated. I am preparing $begin and $end for DatePeriod() but I can't get passed this error "getting the error Recoverable fatal error: Object of class DateTime could not be converted to string". $today = date("Y-m-d"); $datestop=$_POST['datestop']; //echo "$today<br /><br />$datestop<br /><br />"; $begin = new DateTime("$today"); $end = new DateTime("$datestop");
I have a varaiable which gets the server time; $date =date("Y-m-d H:i:s"); suppose the server is in the USA then it the timezone of this date will be the timezone of USA. And i want to convert this timezone to Asia/Karachi timezone. Any Idea about this??? |