Search
 
SCRIPT & CODE EXAMPLE
 

PHP

west african timezone in php

<?php 
  //Specific to Nigeria
  date_default_timezone_set('Africa/Lagos');
	echo date('H:m:s');

//for Nairobi
  date_default_timezone_set('Africa/Nairobi');
	echo date('H:m:s');
Comment

php timezone

date_default_timezone_set("Asia/Karachi");
//if you wand your timezone in whole website than go to config/app.php
// and serch for timezone, now pass your time zone. in my case
'timezone' => 'Asia/Karachi',
//Go to following link to find your timezone
// https://www.php.net/manual/en/timezones.asia.php
Comment

php, Africa timezones

Africa/Nairobi
Comment

timezones 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 :: create auto image path folder in laravel 8 
Php :: middleware command in laravel 
Php :: array shift php 
Php :: keep line breaks in textarea 
Php :: php call method from another class 
Php :: validate names regex php 
Php :: signup api in laravel 
Php :: how to setup cron job for laravel queues on shared hosting 
Php :: laravel db raw count where 
Php :: acos() php 
Php :: how to pass parameters to relationships laravel 
Php :: use php artisan command through controller 
Php :: session_regenerate_id 
Php :: php date() 
Php :: ::latest() 
Php :: flatten in array php 
Php :: how to get the previous page url in php 
Php :: string length laravel validation 
Php :: how to loop by index in php 
Php :: reverse string php 
Php :: language_attributes for wordpress 
Php :: class name laravel 
Php :: WordPress Plugin Definition 
Php :: php multi elseif statement ternary 
Php :: yii2 sendemail extension 
Php :: php language is used for 
Php :: PHP sha1 — Calculate the sha1 hash of a string 
Php :: Skip model mutator 
Php :: how to disable a button in a blade file 
Php :: laravel validation if another record is not deleted / not null 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =