PHP - Seconds To Full Date
Hi all,
I have a database with some timestamps (in seconds) in it. Now I want to reverse it to normal readable time and date formats. Will someone tell me how please. Thnx Ryflex Similar TutorialsHello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. Hey guys! I have the following doubt, I have a Date value and I want to add to that date 30 seconds plus. Example: Code: [Select] $last_time = date('D M j H:i:s \G\M\TO Y'); //echo: Thu Mar 10 18:33:48 GMT-0300 2011 I need the following date: Thu Mar 10 18:33:48 GMT-0300 2011 to become: Thu Mar 10 18:34:18 GMT-0300 2011 This means that the retrieved Date now has 30 more seconds... Any ideas?? Looking forward to any help, Thanks a lot in advance, Cheers! hello, i have the following code and it is ok. what im trying to do is convert a 2010-09-20 post from a form and have it read out as Monday September 20, 2010. is this possible? Code: [Select] $dateselected="$_POST[Y]-$_POST[M]-$_POST[D]"; echo "<table border='1'>"; echo "<tr><td width='100%' colspan='4' align='center'>$_POST[M]-$_POST[D]-$_POST[Y]</td></tr>";
Hi, echo '<div style="float:right;width:60%;color:#666666">'. TeamSpeak3_Helper_Convert::version($ts3->virtualserver_uptime) .'</div>'; Edited June 24, 2020 by Lux05 You: As a PHP expert, you find the prospect of building yet another brochure-ware website distressing; you want to get your hands dirty building an advanced, MVC based application in a fun and supportive environment where you will be constantly challenged, always learning and delivering a product used by millions of people every day.
Our company was founded and is managed by developers who wrote the original software the company was built upon; the technical team are the core of our business. As a member of that team, it will be you who decides upon the on-going development of our technical stack as well as the product itself. You will of course have complete control over your workstation.
Our stack:
Qualifications:
A passion for programming, solving problems and building software customers love.
Experience building web-based applications as distinct from brochure-ware websites.
An expert in OOP/MVC/ORM programming techniques and PHP (v5.3+) frameworks. We happen to use Symfony2 but any relevant experience is fine.
You can bend MySQL to your will.
Solid front-end development experience with XHTML, CSS, and Javascript. Our stack includes AngularJS, CoffeeScript, jQuery and LESS.
An appreciation for a beautiful GUI and excellent user experience.
Expectation of a fast moving, agile environment. We ship code to customers daily – we’d expect you contribute from day 1.
You can validate your skills for example with source code samples, a github profile, contributions to an open source project, developer blog, stackoverflow answers etc.
What you will do:
Design (with help) and develop new channels for our software. In particular we are looking at apps using twilio (for voice/sms), facebook and twitter as well as a web based screensharing tool.
Integrate our software into other 3rd party applications. This could both be via APIs (salesforce, jira, 37signals) or through digging directly into the source code (sugarCRM, xenforo etc).
Continue improve and refine our existing channels and product. We are never satisfied and always looking for that small improvement, refactor or redesign that can increase usability, speed and functionality for our customers.
Work on our backend systems including internal developer tools and deployment processes, our SaaS application stack or the tools we have to manage our business.
Work on our mobile apps, built using our API / HTML5 and PhoneGap
About us:
Our principle product is DeskPRO, the helpdesk software platform. We make it easy for organisations (companies – large and small, charities, public sector organisations) to communicate with their users via email, twitter, facebook, SMS, web forms, live chat (text and voice) as well as providing publishing self-help tools, sales management, co-working tools and community based question and answers. DeskPRO is a platform where customers install the helpdesk applications they need to manage their business.
We sell this software to a range of organisations including large companies (e.g. Tumblr, Xerox, T-mobile, Fujitsu, Valve Software and AT&T) universities and the public sector all the way through to small family businesses. We have a dual license model; selling licenses to software installed on our clients’ servers (we don’t encrypt the code – so your code will get read!) and offering a fully managed SaaS solution. Millions of people use our software every day and a lot of agents spend their whole working day using it constantly.
What we offer:
Competitive salary based upon experience.
Friendly work environment at the Innovation Warehouse in Farringdon: http://theiw.org/.
30" monitor and control over your workstation setup. No corporate bureaucracy here.
A mixture of autonomy over your role and real responsibilities to the team and business.
Varied work. The DeskPRO product is large with lots of modules and technologies.
Review our source code before even applying; just ask and we will add you to our github account. Never accept a job until you have seen the code you will be working with.
We plan to have a lot of fun on this journey – please bring a sense of humour.
Apply:
Please send your CV and either a link to your online profile, github account or some sample source code to: jobs@deskpro.com
Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack I am trying to write a script that is going to access a database, grab the newest picture from it, find the height and width, analyze the height and width to find which command (which is assigned to a variable) is the one to run, run that command in the terminal, and then access the database again 6 seconds later (new pictures are uploaded every 6 seconds) and re-run and enter the command for this new picture. I have most of this already done, the problem I am having is figuring out how to get this to run every 6 seconds for forever. (Yes it has to be every 6 seconds.) Can anyone help me? Thanks in advance for the help! How do I echo the time in SECONDS? $tz = new DateTimeZone('America/Chicago'); $date = new DateTime('now', $tz); $mtime = $date->format('Y-m-d H:i:s'); echo ($mtime); E.g. 1296057739 Hi! I have got a problem with this function: Code: [Select] <?php function Sec2Time($time){ if(is_numeric($time)){ $value = array( "years" => 0, "days" => 0, "hours" => 0, "minutes" => 0, "seconds" => 0, ); if($time >= 31556926){ $value["years"] = floor($time/31556926); $time = ($time%31556926); } if($time >= 86400){ $value["days"] = floor($time/86400); $time = ($time%86400); } if($time >= 3600){ $value["hours"] = floor($time/3600); $time = ($time%3600); } if($time >= 60){ $value["minutes"] = floor($time/60); $time = ($time%60); } $value["seconds"] = floor($time); return (array) $value; }else{ return (bool) FALSE; } } ?> and my output for example: echo Sec2Time(604800); returns = "Array" ?? What I am wanting is to return a time from how many seconds. 604800 is 7 days so I want it to say 7 days. 2419200 is 1 month so I want it to say 1 month or 4 weeks. is (above) the right function for what I want ? thanks. I'd like to make an sql request every x seconds with php. is it possible? I need to get the +10 timezone. But 1. The output for +10 is incorrect. Please help to fix it. 2. Is this a good way to get it? <?php echo "time=" (.time() + 36000); ?> Hello, I'm working on a simple project so bear with me, I have a variable called 'wood' on my SQL database, and I want to somehow increase the 'wood' value (int) every 5 seconds... Even when the user is not currently view that page. So what I'm thinking is saving the current mktime() to my database once - for sake of argument, this is going to be called 'time_cache', as well as the wood(int) variable. Then, when the user logs in to see how much wood there is, the PHP will, take the mktime() and subtract the 'cache_time' to see how many seconds have passed... Now I want to increase the wood int by 1 every 5 seconds that have passed. So I guess I need to do a division such as $seconds_passed = (mktime() - $time_cache) / 5. Which will give me the amount of 5 seconds that have passed, right? Then, surely my $wood will just equal $seconds_passed? I'm not sure if this is the best way to do something like this? Any one else have an idea? Also, my wood value doesn't 100% work as it give a decimal... I just want the wood value to increase by 1, every 5 seconds. Hi, I want to update a row when 30sec are passed on a page. If not nothing happens(not updating row). Example: You go to example.php>> 30sec pass, update row>> 30sec not over, no update. it does not necessarily have to be second it can be minutes or hours. Who can help me? Hope its clear enough, Thanks. Hi. I have a query that determines if user is online/offline. Works perfectly when page loads. I want to change to auto run query every X seconds. NOTES: - The query is on a .php page with multiple other queries. -IF it is possible to still run the query with-in this page? or make a separate file and include in an iframe? i would like to avoid the iframe and just $output the result of query every X seconds. Here is my $query code: $query = "SELECT `manager_id` FROM #__profiles_xref WHERE profileid = '$profid'"; $onofflineid=doSelectSql($query,1); foreach ($onofflineid as $isonoffline){ $profmanagerid=$isonoffline->manager_id; } $query = "SELECT `session_id` FROM table_session WHERE userid = '$propmanagerid'"; $onofflinestatus=doSelectSql($query,1); if (count($onofflinestatus)>0) { $output['PROPSTATUS']='Online'; } else { $output['PROPSTATUS']='Offline'; } I think I'm seriously missing some small thing to get this code to just auto refresh after (x) seconds or after video completes fully. This is for users to watch from a database of other users that submitted url's - right now all I could put a skip button to auto-refresh. If anyone can help or at least point me into the right direction on some snippets I can kind-of work off of. here is the snippet (kind-of a big snippet) Code: [Select] <? include('header.php'); foreach($_GET as $key => $value) { $secure[$key] = filter($value); } if($_GET['a'] == "skip"){ $sit1 = mysql_query("SELECT * FROM `youtube` WHERE `id`='{$secure['id']}'"); $sit = mysql_num_rows($sit1); if($sit > 0){ mysql_query("INSERT INTO `viewed` (user_id, site_id) VALUES('{$data->id}','{$secure['id']}')"); }} ?> <div class="block medium right"> <div class="top"><?if(isset($data->login)) {?> <h1>Earn Coins - Youtube</h1> </div> <div class="content"> <? // fetches all "unplayed" youtube videos for this user // $site2 = mysql_query("SELECT * FROM `youtube` WHERE (`active` = '0' AND `points` >= `cpc`) AND `id` NOT IN (SELECT `site_id` FROM `viewed` WHERE `user_id`='{$data->id}') ORDER BY `cpc` DESC LIMIT 0, 1"); $site = mysql_fetch_object($site2); $ext = mysql_num_rows($site2); if($ext > 0){ ?> <script src="js/swfobject.js"></script> <script type="text/javascript"> var playing = false; var fullyPlayed = false; var interval = ''; var played = 0; var length = 30; function YouTubePlaying(){ played += 0.1; roundedPlayed = Math.ceil(played); document.getElementById("played").innerHTML = Math.min(roundedPlayed,length); if (roundedPlayed == length){ if (fullyPlayed == false){ YouTubePlayed(); fullyPlayed = true; } } } function YouTubePlayed(){ var response = '<? echo $site->youtube;?>'; var username = "<? echo $data->id;?>"; $.post("ytreceive.php", { data: response + "---" + username}, function(result){ if(!isNaN(result)) { var curr_val = $('#points').text(); var new_val = parseInt(curr_val)+parseInt(result); $('#points').text(new_val); } } ); document.getElementById(response).style.visibility = "visible"; } function onYouTubePlayerReady(playerId){ ytplayer = document.getElementById("myytplayer"); ytplayer.addEventListener("onStateChange", "onYouTubePlayerStateChange"); } function onYouTubePlayerStateChange(newState){ if (newState == 1){ playing = true; interval = window.setInterval('YouTubePlaying()',100); }else{ if (playing) window.clearInterval(interval); playing = false; } } function refreshpage() { window.location.reload(); } </script> <center> <div style="width: 520px; padding: 10px;"> <h3>"<? echo $site->title;?>"</h3> View this video for 30 seconds and after that you will receive <? echo $site->cpc;?> coins<br/><br/> <div id="ytPlayer">You need Flash player 8+ and JavaScript enabled to view this video.</div> <script type="text/javascript"> var params = { allowScriptAccess: "always" }; var atts = { id: "myytplayer" }; swfobject.embedSWF("http://www.youtube.com/v/<? echo $site->youtube;?>?enablejsapi=1&playerapiid=ytplayer&autoplay=1", "ytPlayer", "425", "356", "8", null, null, params, atts); </script> <br/> <br />Must play for <span id="played">0</span>/10 seconds (<a href="youtube.php?a=skip&id=<? echo $site->id;?>" style="color:blue">Skip</a>) <div id="<? echo $site->youtube;?>" style="visibility:hidden"><a href="javascript:refreshpage()">View Next Video</a></div> </div></center> <?}else{?> <div class="msg"> <div class="error">Sorry, there are no more coins to be earned at the moment. Please try again later.</div> <div class="info"><a href="buy.php"><b>Feel like you need more coins? You can purchase them now!</b></a></div></div> <?}}else{?><script>document.location.href='index.php'</script><?}?> </div> </div> <?include('footer.php');?> Ok Let's say I have a timestamp: 1327482941 I want to convert this to output only "60" im not looking for a whole time_ago function, simply just need to convert a timestamp down to seconds ONLY not having minutes/years/etc no need none of that just purely seconds starting from 1-60 if so how is it possible? I tried to just Code: [Select] $seconds = substr($e,1,4) . ""; $e is my timestamp, I did this because I could just grab the last 2 digits in the timestamp that would be what I want, but that's not possible because it goes 1-90 not 1-60 ^_^ help Here is a code I am trying to make it only spit out 1-60 in seconds Code: [Select] function timeAgo4($timestamp, $granularity=1){ $difference = $timestamp; if($difference < 0) return '0'; elseif($difference < 86400){ $periods = array(60,'' => 1); $output = ''; foreach($periods as $key => $value){ if($difference >= $value){ $time = round($difference / $value); $difference %= $value; $output .= ($output ? ' ' : '').$time.' '; $granularity--; } if($granularity == 0) break; } return ($output ? $output : '0').''; } else return date($format, $timestamp); } I have a client who wants to use an animated GIF as his logo. It's a pretty cool animation but once the animation stops, the "static" logo isn't very clear. Is there some way (with either PHP or any way really) to have an image be replaced after a certain amount of time (say 5 seconds) with another image? In other words, when a page loads, the animated GIF will load first and after 5 seconds of that initial animation, the GIF logo will switch to a much clearer PNG logo file. Yes, I know I should just learn Flash and recreate the animation in Flash, but I don't have that ability right now Thanks everyone! Have started to program my own cricket management game and wish to have the database update every 60 seconds; this is to facilitate players who are not watching the actual game. Games are starting (and finishing) at all times so it is not possible to allow the user to be the only one to activate the game code; it is also not possible to only play the games when the human players are online because other games depend on the results. The only answer I can think of at the moment is to have a copy of firefox running on the server which runs the PHP code to update all current games and have this page automatically refresh every 60 seconds. Is this even viable? Any other suggestions? James Hello!
I am trying to display content that will only be displayed for 30 seconds to each visitor. I want to have a unique ID given to each user that visits my page and also add that assigned ID to the end of the URL. If the page is loaded again after 30 seconds, I want the unique user ID to redirect using header();
So When a suer visits my page, I want the end of the url to have “userid=“ like this:
http://example.com/page.php?userid=0000000001If that user comes back to the same url after 30 seconds, I want to redirect using header(); How do I do this? what is the best way? Edited by supertooper, 01 September 2014 - 10:41 PM. Hi, I have some queries that update some statistics in a table I have. I need these queries to run only after 15 seconds have passed however. This way if the user leaves before the 15 seconds, the queries won't run. I've tried using Sleep, however it seems to just stop all the code all together for the allotted time. There must be a way to do this. |