Viewed   79 times

How can I get the timestamp of 12 o'clock of today, yesterday and the day before yesterday by using strtotime() function in php?

12 o'clock is a variable and would be changed by user.


$hour = 12;

$today              = strtotime($hour . ':00:00');
$yesterday          = strtotime('-1 day', $today);
$dayBeforeYesterday = strtotime('-1 day', $yesterday);
Saturday, December 17, 2022

Due to a daylight savings shift, 28/10/12 has an extra hour in your timezone. There are 25 hours between midnight 28/10 and midnight 29/10.

You will also find a day with 23 hours in spring.

If this is not what you expect, change the timezone to something that has no DST. UTC is one option:

php > echo mktime(0,0,0,10,29,2012) - mktime(0,0,0,10,28,2012);
php > ini_set('date.timezone', 'UTC');
php > echo mktime(0,0,0,10,29,2012) - mktime(0,0,0,10,28,2012);
Tuesday, September 20, 2022

The last one should be gmdate instead of date:

'<b>Time difference::</b> ' . gmdate('h:i:s', $time_diff);

date adjusts for your current locale, which appears to be GMT+1. gmdate does not make that adjustment.

I'm assuming that you're only planning to use this for time differences less than 24 hours.

Saturday, December 24, 2022

I understand the question and the answer is going to be complex. First you need to add onChange event to your ProducerType selectbox. Add this at the end of your html:

   // attach event on change
      // call script on server to check if isset() and receive values for Role
               // here the script on server returned data already
               // update Role selectbox with new values

Make sure you have jquery.js loaded as usual.

You will need to create a PHP script on server which handles the check and returns new data for your select input. Like this (save as "checkproducer.php"):

    if ($_GET['ProducerType']=="Principal")
       echo "<option value=1>Principal1</option>"
           ."<option value=2>Principal2</option>";
    if ($_GET['ProducerType']=="Producer")
       echo "<option value=1>Producer1</option>".
           ."<option value=2>Producer2</option>";
    if ($_GET['ProducerType']=="SoleProprietor")
       echo "<option value=1>SoleProprietor1</option>"
           ."<option value=2>SoleProprietor2</option>";

    // etc
Friday, September 9, 2022

getID3 supports video formats. See:

Edit: So, in code format, that'd be like:

$getID3 = new getID3;
$file = $getID3->analyze($filename);
echo("Duration: ".$file['playtime_string'].
" / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
" / Filesize: ".$file['filesize']." bytes<br />");

Note: You must include the getID3 classes before this will work! See the above link.

Edit: If you have the ability to modify the PHP installation on your server, a PHP extension for this purpose is ffmpeg-php. See:

Friday, December 23, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :