Converting TIMESTAMP Fields Into "real Time"?
Is there a code for converting a db field that is TIMESTAMP into "real time"?
Meaning if the field is 2007-03-21 10:51:28have is output: "10:51 am",
Or: 2007-03-21 13:51:28output: "1:51pm"?
View Complete Forum Thread with Replies
Related Forum Messages:
Converting An SQL TIMESTAMP Into Unix Timestamp
I look over the docs on MySQL, and I'm assuming MS SQL will be quite similar. I am trying to decide how best to pull this off. I am anticipating a need to take the typical SQL TIMESTAMP and convert it to an Unix Timestamp... Now, as I look at this a TIMESTAMP stores namely a "numerical" format in a 14 Digit String. I'm just wondering if anyone has a suggestion as to how I might split this into the componenets (4d Year/3d Month/2d Day/HH MM SS) so that it could be passed through mktime() (which will give me the unix version). Actually, I think I may have an approach.. perhaps using the php substr() function.. since it returns a "defined" portion of a string.. if $x was our timestamp, we'd have to pass it through the substr() function a few times, to pull out the pieces we wanted.
View Replies !
Converting Html Code To Real Line Breaks In A Textarea
I am having some trouble with converting html code to real line breaks in a textarea, I have the following code that I gets html code from a database and then puts it into a textarea but the str_replace I am using converts the text but puts the actual characters in the textarea, and doesn't actually turn it into a linebreak. (the br below is reality in triangular brackets!) $paragraph=$row['paragraph']; $paragraph=str_replace('br',' ',$paragraph); ..... <textarea name="ud_text" cols="50" rows="15" maxlength="300"><? echo $paragraph ?></textarea> Perhaps someone can help me with this?
View Replies !
Converting Timestamp To EST
i'm trying to get my script to change the timestamp into EST because the time i am getting now is showing me 4 hours behind. here is the coding PHP Code: $con_time=$serv1->fetchMatchingArray("PLAYEDAT"); if (preg_match ("/^[0-9]{10}$/", $con_time[0])) { Â Â Â for ($i=0; $i<count($con_time); $i++) { Â Â Â Â $con_time[$i] = $con_time[$i] + $adjust; Â Â Â Â $con_time[$i] = date('h:i:s a', $con_time[$i]); Â Â Â Â Â Â Â } Â Â Â $playtime = $con_time; Â Â } else { Â Â Â $playtime = $con_time; Â Â } if ($timeat == "0") { Â Â Â Â Â Â $playat = array_shift ($playtime); Â Â Â } else { Â Â Â Â Â Â $playtime = $playtime; Â Â Â } am i missing something when i am trying to get it to display time. Right now a timestamp of 1128618980 is coming out as 12:16:20 pm and it should be 4:16:20 am.
View Replies !
Converting Timestamp
I have been trying to figure this out, and finally noticed what is causing the problem. I don't know how to fix it though. PHP Code: // mysql query picks up the timezone. mine is 1 $newdate = date('n/j/y g:i a', strtotime($sql->timezone . ' hours', strtotime($fulldate))); If the strtotime($fulldate) = 8/2/07 0:01 am, the date comes out looking like this : 12/31/69 5:59 pm how do I fix that?
View Replies !
Converting MySQL Timestamp
I was wondering if it was possible to convert a MySQL Timestamp to a regular date format. I've tried time($row->date) and echoed the $row->date variable but it has no effect on the format. I found this time($row->date) thing at php.net but it didn't do anything that I wanted. I'm trying to display a readable date from a MySQL Timestamp.
View Replies !
Converting Timestamp Into Minutes And Seconds
I am timing employees who take a test. I have the start time and end time, which are unix epochs, and subtracing the start from the end will give me a large number of seconds, for example 552. I want to convert this into minutes and seconds.
View Replies !
Converting A Date To Unix Timestamp
I have a form where people enter their birthday_day, birthday_month, and birthday_year Is there a way to do the following; convert_this_to_unix_timestamp($_POST['birthday_day'], $_POST['birthday_month'], $_POST['birthday_year']); The point is that if i store it as a unix_timestamp, then i can do some math on it and return the users age instead of their birthday.
View Replies !
Converting Stored Unix Timestamp
I'm using MySQL, and storing dates as unix timestamps in the database. Can I convert these to formatted dates within the SQL query, or can I only do it in PHP? MySQL seems to have a lot of functions to work with MySQL-format dates, but they only appear to convert TO unix dates, not FROM them. Is this true?
View Replies !
Real-time Output?
I'm a relative PHP newbie, so I apologize if this is a simple question. Anyway, here's my problem. I'm using a PHP script to pre-render a bunchload of insert files for an HTML page. Right now there's about 1,600, but that number could get much, much higher when the site goes live. I'll only need to re-render the whole batch once or twice a year (if that) but it's still something I'd like to be able to do in case I have to move the site to a different server, or there's a hard drive crash or etc. Basically what the script does is grab a whole bunch of information from a database and write the insert file. It does this for every single one. The problem of course, is that PHP by default does all this server-side, and then sends it to the browser. Because this process takes like ten or twenty minutes to do, the browser times out long before it's finished. Is there a way to get progressive output with PHP? Or do I need to re-do this in another language like Perl?
View Replies !
Real Time Chat
There's anyone out there that can give me a light on real time chat using sockets. I've seen some using push technics but they all hang up after an elapsed amount of time.
View Replies !
Real-time Clock
Where should I start to write a Real-time Clock? I want it be dynamic, not static. I know how to get the time and display it but how do I keep changing it ?
View Replies !
Real-time Chat
I wrote a PHP chat system similar to gChat which simply uses constant ajax calls to update the chat. This system is fine for a few users, but with potentially thousands of users, it is much too hard on the server. I've been considering taking the 'Comet' route, but have heard that PHP can't handle Comet very well. What would be the best language/API to perform real-time chat for a large user-base?
View Replies !
Real Time Sql Query
I am making a web-based chat but to get the msg from the database i need to refresh the page and that will make load and extra bandwidth on the server so i want to make the query in real time ( only the new msg to be received without refresh the whole page ), Any one in here knows how to get data from sql database without having to refresh page.
View Replies !
Regex Issue - Converting A Written Date To A Timestamp
I have a problem, somehow through one of my scripts, all the timestamps in my database were set to 0000-00-00 00:00:00. I can fix this because one of the fields contains the written date in this format "Wednesday, June 7, 2006", I think I need to make a regex expression that can read that and generate a new timestamp from it, I'm just not sure where to start because I've barely used regex. Some of the dates are not in that format because it contains over two years worth of data, and I want to just delete the ones that are not in that format as well. I'd appreciate any help here, I'm kind of stumped. Once I match the expression I can generate the timestamp, but I don't know how to match it.
View Replies !
Real Time Echo'ing Of Var In A Loop
i have a big loop, and rather then waiting until its done for me too see what happened, every time it runs, how can i get the browser to echo the result, and proceed to keep running the loop. basically this loop takes a long time to finish, and i had to set my max runtime past 30 seconds. i guess incorporating a refresh of some sort like this would eliminate the need for the time extension too?
View Replies !
Real Time Form Update
i have a script that i wrote for my clan/guild/linkshell in this online game i play that keeps track of members, the points they receive from events, items etc. in the admin panel of the script where you can update peoples points i want to know if i can add a button or something similar that if you push it updates the points which is currently in another text box in the same form in real time. I'm sorry if i'm not being clear, what i'm trying to do it make it quicker to update a members points because usually after each event they receive either 10 or 20 so i want to add a button where if you push it then it will put 10 or 20 in the 'add' box in real time. right now when you edit a member it shows their current points in a text box and under that two text boxes, one if you want to add points and another if you want to subtract points. if this isnt possible then i assume that i'd have to make it update the points in the box and keep all the values from before and just reload the page with the new value inside the box. wow, i'm sorry if i'm not very clear, please ask questions if you dont understand what i'm trying to say.
View Replies !
Real-time Action Ala Games??
What would be a proper solution for automated decision making in a PHP script, like a game? That is, without an external application, or any human input. For example, any random event that happens when the player is away from the game. How would one go about implementing that?
View Replies !
Real Time Listbox Update
I have one listbox that I populate with while($row = mysql_fetch_array($result, MYSQL_ASSOC) I need to in real time populate another listbox from a related table based on what they have currently selected in the first listbox. Is this possible with php and if so.
View Replies !
Read Data From MS Access Into MySQL In Real-time
I am currently working on a project that involves reading information from a inventory system into Access via ODBC and display the info on the web site using MySQL. I would like to create a live link between the MS Access(local) and MySQL (remote) whenever the inventory system is updated MySQL will be updated as well. I know that MyODBC will let me do the opposite of what I would like to accomplish by reading data in MySQL into Access. Is it possible to do the reverse way.
View Replies !
How Can One Get Real Time Stock Quotes For An Online-community?
For one of our web-communities we plan an offer of real time stock quotes incl. advanced notification services. I have the following questions: - Do you know of any services, that already offers such services in a decent way? And more important: - Does anybody know a provider of such services, that offers a real-time stock quote data stream for such a usage at a decent price? I only know of Deutsche Börse offering it for 1駨 Euro per month. That is too expensive for us.
View Replies !
Converting MySQL Fields To HTML
I have a VARCHAR(255) field in a MySQL database that contains Carriage Returns and Line Feeds. I'm trying to display the contents of this field in html with printf, but the CrLf's are being ignored by the printf. Does anyone know an easy way of parsing a string with CrLf's into HTML?
View Replies !
Converting Form Fields Into An Array
I have a form that enters inventory values based on date. Each day has a certain inventory value. Some days of the month have the same inventory values. I have 31 checkboxes, one for each day of the month and the inventory value form field. I enter the inventory value and then check the days that the inventory value applies to. When inserting the data into the mysql database, I would like to loop through the days and if a day is checked, then I run the mysql query to insert the data. How do I convert all the checkboxes into an array or is there a better way to do it?
View Replies !
Text Input Of Date And Timestamp Fields
I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the best way to create date or timestamp inputs. Let's take a date in the format yyyy-mm-dd as an example. This is too error prone, I know my users will do it wrong <input type="text" name="fieldname"> Right now I'm thinking about something like this: <input type="text" size="4" name="y_fieldname">- <input type="text" size="2" name="m_fieldname">- <input type="text" size="2" name="d_fieldname"> but this is IMO a very ugly solution, because after the SUBMIT I have to glue all the parts together before inserting the values into the db. Something like this: <input type="text" format="yyyy-mm-dd" name="fieldname">
View Replies !
Time, Timestamp?
I have a mysql db that contains a timestamp= 20010626114705 When I use getdate() to convert this to the correct date I get: $today = getdate($tijd); $month = $today['month']; $year = $today['year']; $mday = $today['mday']; $hours = $today['hours']; $minutes = $today['minutes']; $weekday = $today['weekday']; echo "$weekday $mday $month, $year $hours : $minutes"; = Monday 18 January, 2038 22 : 14 any ideas what is going wrong?
View Replies !
Converting To Time
I am facing problem in converting to time. select sec_to_time(unix_timestamp(now())-unix_timestamp(timestamp)) from Tablename where name= '".$name."'"; Here when values exceeds 838:59:59 how to get the exact value of time. Other than sec_to_time() is there any other function which gives the exact value
View Replies !
Converting Time
I have an application that gives me numbers like 1183354915 and the php coding converts it into a time. print date('d m Y', $row['topic_time']); Are there any converters that will allow me to input July 2, 10:59PM and it will spit out that number?
View Replies !
Dropping The Time From A Timestamp
I am looking to display the date in a field but I can't figure out how to make the timestamp drop the hours:minutes:seconds. My timestamp originally comes in formatted like "2006-01-01 00:00:00" and I wish to have it read "2006-01-01" only. I've tried using the echo (date("Y-m-d",$row_getProject['EndDate'])) but it returns an error that reads: Notice: A non well formed numeric value encountered in C:htdocsadminEditProjects.php on line 109 1969-12-31 and it adds the date of 1969-12-31 for some reason. Does anyone know how I might be able to solve this issue?
View Replies !
What The Timestamp From Time() Format Is
I am trying to decipher what the unix time below represents. Through my searches, it represents the seconds past from a certain date past. Is that correct?? 1063115283 I am writing a script that does something after 10 minutes have passed. would 10 minutes be 10 *60 = 600 ?? Would that have to be the difference?
View Replies !
Getting Date (timestamp) As Time Value?
I'd like to read out a date from the a DB, but as time var. By default I seem to get it as a string. E.g. while(odbc_fetch_row($result)) { $tt= odbc_result($result,2); echo date("d.m.Y", $tt).", ".odbc_result($result,6) . " <br>";
View Replies !
Getting Time Of Day From Unix Timestamp
I'm working on my CMS, Thacmus, and I've run into one helluva snag (well, nothing big). I'm working on adding the time of day to my date field, since I've procrastinated on that, but I'm having trouble trying to get the time of day from the timestamp without it interfering with the day. I've managed to supress this with the two asterik'd Here's the code for the two fields, date, and time: Code:
View Replies !
Timestamp To Readable Time
I am trying to get the amount of time logged in for the people that use my site. It works although I use date function to display the time which is in timestamp format therefore it always shows 1 hour e.g. if you have been logged in for 20min it would show 1.20 (1 hour 20 min or 20 past 1 as this is a date). With this function the left most number can never be 0 therefore I must change the fucntionto something else. Code:
View Replies !
Timestamp To Time Passed
I am currently using a script that calculates the difference between two timestamps and returns a string like, "35 weeks 22 hours 9 minutes ago". I am using a modified version of a script you can find by Googling "timestamp_to_time_passed". I am wondering if anyone has a solution or knows of a script where I could include months and years. This would have to take into account different month's lengths, leap years, etc.
View Replies !
Return A Timestamp From DB With Just The Time
I need to return a timestamp from my DB with just the time, however, the script that is inputting the timestamp is from a different timezone and hour ahead of me. I need to return the time less one hour so that it reads right. This is the script that I have right now: $string .= date('h:i:s a',$coord[0]['time']).'<br>'; I know I need to put the SUBDATE function in there somehow, I'm just not able to figure out where. any ideas?
View Replies !
SQL Date/time Or Unix Timestamp?
Generally when developing applications I use unix timestamps as the method of storing dates in a sql database. However, I was wondering if I should use the standard date-time used by the database. The question then arises: continue using PHP to manipulate the dates, or allow the sql server to take over. Can anyone provide any reasons to use sql date-time rather than unix timestamps?
View Replies !
Mysql Time/timestamp Types
Is it possible for mySQL to autofill these fields if an insert script is succesful? How could this be done? Is it better to generate a time using the mktime()/date function in php first?
View Replies !
Timestamp Display Incorrect Time
This is the code that I use to display the current time. <?php $timestamp = time(); $date_now = date('m/d/y g:i a', $timestamp); print $date_now; ?> It is 12:03pm at where I live (USA West) But for some reason the above code gives me 08/28/05 4:03 am Is there a way to specify the time for US West?
View Replies !
Converting Integers Into Time
Say you had a number 34. Now i want to convert that to time by making it become 3 hours and 40 minutes.. in a time stamp manner.. On top of that say the number rolled above a 6 (suggesting 60 minutes) itll roll on to the next time line like: 364 becomes(36 - the 6 rolls over to the 3 so 3+1 = 4) which makes 44 is 4 hours and 4 minutes. then this would become 4 hours and 40 minutes as the hundred mark infact adds onto hour... How is this done and also put into a time stamp?
View Replies !
Converting UTC To Local Time
My PHP connects with a postgresql database and fetches the last login information of type "timestamp with time zone". The database returns this value: 2007-08-06 19:05:14.551719-06, but the actual time I have right now is 9:05:14 PM. I assume the time given by the database is in UTC. Now, how do I convert this to respect the local time of the user seeing this? For example, I am located in eastern time zone and I should be seeing 9:07:14 PM, but someone in central time zone should be seeing 8:05:14 PM. Is there a PHP code that can convert this time into the local time of the current user viewing the time depending on his geographical location?
View Replies !
Get The Mysql Timestamp Converted To The Way Time() Displays It
I have a field in a mySQL table that is defined as timestamp. It auto updates itself whenever I do an update on the record. I want to be able to take the current time and compare it to the time in the record, and find out how much of a time difference exsits between the two in hours, mins, secs. I'm currently using time() to get the current time, but it seems that the time returns things in a different format then timestamp stores in. If I can get the mysql timestamp converted to the way time() displays it, then I'd assume I could just do some division as the time() is in the # of seconds from some date in the 70s.. correct?
View Replies !
Timestamp / Unix Time Stamp Querying...
Im baffled, officially! Okay. I have a table. ORDERS --------- ID DateTime Value DateTime is generated by PHP and is a UNIX timestamp. I need to return all the orders, that were placed, say, between 4-5pm, on whatever day. I see a few functions that should help me, FROM_TIMESTAMP, HOUR, INTERVAL... but um... i just cant seem to crack how to do it... can someone just boot me in the right direction?
View Replies !
Unix Timestamp Into Textual Date Time
How do i convert a Unix timestamp into English textual date time description? In my database i have stored the date and time as 1187079740 and now i want it to be converted into 14/08/2007 13:52:20. I have currently used <?php $format = '%d/%m/%Y %H:%M:%S' $strf = strftime($format); echo "$strf "; print_r(strptime($strf, $format)); ?> I am generating data from a db to xml which gives date as <date>1187079740</date> Now my task is to convert SPECIFICALLY the value 1187079740 into it's actual textual form of 14/08/2007 13:52:20. I want the data 1187079740 to be written into a php script to generate it's textual time.
View Replies !
MySQL TIMESTAMP Field And PHP's Time() Function
I have a table in MySQL with a field of type TIMESTAMP, whenever i try to insert some value in it using : "INSERT INTO mytable set myfield=" . time(); It gets doubled or tripled i.e. it gets multiplied by some ratio. and when i extract that value and try to format the output with the date() function it shows some day of 2038.... Is there any incompatibility in TIMESTAMP and time() ?
View Replies !
|