Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php strtotime

echo strtotime("now"); //1624416532
echo date("d M. Y", strtotime("now")); // 23 Jun. 2021

$time_c = strtotime("2021-06-07 05:57:51");
echo date("d M. Y", $time_c); // 07 Jun. 2021
echo date("H:i", $time_c); // 05:57
Comment

strtotime php

<?php
 
  /* This answer is about date and time
 
  The syntax for date and time is:
  */
 
  date(format,timestamp)
 
  /* Here, format is required and it specifies the format of the timestamp,
  while timestamp is optional and specifies a timestamp. Default value
  for timestamp is current date and time */
 
  #Some characters that are commonly used for dates are:
  
  l (Lowercase L) - Represents day of the week
  d - Tells the day of the month
  m - Tells the month of the year
  Y - Represents a year
  
  echo "Today is " . date("m/d/Y") . "<br>";
  echo "Today is " . date("m.d.Y") . "<br>";
  echo "Today is " . date("m-d-Y") . "<br>";
  echo "Today is " . date("l");
  
  #Some characters that are commonly used for time are:

  H - 24-hour format of an hour (0 to 23)
  h - 12-hour format of an hour (0 to 12)
  i - Minute with leading zeros (0 to 59)
  s - Seconds with leading zeros (0 to 59)
  a - am or pm
    
  echo "The time is " . date("h:i:sa");
  echo "The time is " . date("H:i:s");

  #Set timezones

  date_default_timezone_set("America/New_York");

  #You can access every timezone here: https://www.php.net/manual/en/timezones.php

  #The timezone by default is UTC

  #mktime()

  mktime(hour, minute, second, month, day, year) #Syntax
    
  $d=mktime(01, 1, 1, 1, 01, 0001);
  echo "Created date is " . date("Y-m-d h:i:sa", $d);

  #strtotime
  
  $d=strtotime("4:33am December 6 2011");
  echo "Created date is " . date("Y-m-d h:i:sa", $d);

  $d=strtotime("tomorrow");
  echo date("Y-m-d h:i:sa", $d) . "<br>";

  $d=strtotime("next Saturday");
  echo date("Y-m-d h:i:sa", $d) . "<br>";

  $d=strtotime("+3 Months");
  echo date("Y-m-d h:i:sa", $d) . "<br>";

  strtotime(time, now) #Syntax
    
  #Due to limitations, there is another page for every other thing of Date and Time
    
  #Search "Date and Time PHP Continued"  
  
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php change string to url friendly 
Php :: php get total amount of days in month 
Php :: laravel base64 decode save file 
Php :: wordpress check if class exists 
Php :: how to add recaptcha to woocommerce register php 
Php :: invalid datetime format 1292 
Php :: laravel model particular column 
Php :: php random string 
Php :: deactivate plugin wp cli 
Php :: php reduce 
Php :: query builder "not in" laravel 
Php :: how to separate integer from string in php 
Php :: php regex file extension 
Php :: wordpress query multiple post ids 
Php :: php sql query where in array 
Php :: laravel eloquent where id not equal to 
Php :: if object or array in php 
Php :: wordpress plugin add stylesheet 
Php :: how set field after another field in migration in laravel 
Php :: php jquery plus 1 day 
Php :: laravel clear page cache 
Php :: How to validate a file type in laravel 
Php :: cron run 1 time 
Php :: laravel elasticsearch migration in laravel 
Php :: wordpress is home page 
Php :: the posts pagination 
Php :: laravel exists eloquent 
Php :: migrate specific file laravel 
Php :: LARAVEL CREAT NEW TEST 
Php :: php sort associative array by specific value 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =