Skip to content

How to get total time from several date ranges in php

I have several date ranges in form of DateTime $begin, DateTime $end. Those ranges can overlap in every possible way: etc. What I am trying to do is to get length (in seconds or DateInterval) of those ranges between start of the first one and the end of the latest one (fourth in the case above), excluding reg…

utf8 not showing hyphens correctly in echoed text

my MySQL database is set to utf8_unicode_ci and I have $pdo->exec(‘SET NAMES “utf8″‘) as part of the following php code yet when I echo text from the query a hyphen – looks likes this –. What am I …

WordPress database error MySQL server has gone away for query

I get this error so frequently that the php_error log file increases 1MB every 2 seconds. and the site is very slow. I have tried to add this line to wp-db.php but it did not help. The web server is IIS 7, latest version of mysql and wordpress Answer This trick will work for all WordPress versions. Open your …

How to return a line number in a PHP script

Is it possible for a PHP script to return a line number in which some command is called? I’m having trouble describing what I want so maybe an example. I have PHP code that calls MySQL on many occasions. In line 49 is: The text “line 49” I wrote manually. Is it possible to get this number &#…