SlideShare a Scribd company logo
1 of 9
Download to read offline
For date and time function we know first few things in our
mind
Date and time function
Capital S Year Day Month
Th,rd,st y—17 d=06 m=03
Example--1st Y—2017 n= 6 M=mar
l= Monday,tue.... F=march
D=Mon J=3
By using
[date_default_timezone_get();
using this function we can get the
time which is by default set.
date_default_timezone_set(“Asian/Calcutt
a”);
By using this function we can get the
current time of the current city or
country.
To set the time
 date_default_timezone_set(“Asian/Culcu
tta”);
 Echo date(“h:i:s a); date(h:i:s A);
 Date(h:i:p); date(h:i:s P);
 Am-anti mariadian
 Pm-post mariadian
Define the time
 G-24hr-1,2,3,4,5---------13,14,15,--------
22,23
 H-24hr-01,02,03,04,05----13,14,15------
22,23
 g-12hr-1,2,3,4,5,--------11,12,1,2,3,-------11
 h-12hr-01,02,03-----11,12,01,02,03-------11
 date_default_timezone_set(“Asian/Calcutta”)
;
 echo date(“d,l,F,y,g:i:s a”);
 Output- 06,Monday,March,17 10:58:06 am
Example
We also get output like below
 echo date(todayis l);
 Output---today is Monday
 echo “today is “.date(“l”);
 Output---today is Monday
echo time();
 By using this function we can get the number
of seconds and we can also call it as unix
timestamp. (1971-2017(or current time))
 echo (time()-1296000); 129600 is 15 days sec
 echo date(“y-m-d h:i:s a”,(time()-+1296000));
 o/p-17-02-19 11:10:50am (15 day back if -
1296000) or +1296000 then its (17-03-21
11:10:51)
Strtotime();
using this function we can get
the time of befor or after any
year (like 10 years ,20 years
before or after)
 strtotime(-10 years);
 strtotime(+20 years);
Example-difference between the date or years
 $birth=“1990-02-12”;
 $past=strtotime($birth);
 $curr=time();
 echo(($curr-$past)/(86400*365)); year
 86400 is seconds for a day
 echo(($curr-$past)/(86400*30)); month
 echo(($curr-$past)/(86400*7)); week

More Related Content

Viewers also liked

Horarios y aulas primer cuatrimestre 2017- al 01 de marzo 2017
Horarios y aulas  primer cuatrimestre 2017- al 01 de marzo 2017Horarios y aulas  primer cuatrimestre 2017- al 01 de marzo 2017
Horarios y aulas primer cuatrimestre 2017- al 01 de marzo 2017
Voces Del Valle
 

Viewers also liked (16)

Lei prince el padrino de la bachata
Lei prince   el padrino de la bachata Lei prince   el padrino de la bachata
Lei prince el padrino de la bachata
 
Çiçeklerin Dünyası, World of Flowers IV
Çiçeklerin Dünyası, World of Flowers IVÇiçeklerin Dünyası, World of Flowers IV
Çiçeklerin Dünyası, World of Flowers IV
 
Peningkatan mutu agregat ringan beton bertulang ringan struktural untuk bangu...
Peningkatan mutu agregat ringan beton bertulang ringan struktural untuk bangu...Peningkatan mutu agregat ringan beton bertulang ringan struktural untuk bangu...
Peningkatan mutu agregat ringan beton bertulang ringan struktural untuk bangu...
 
Engineering geology & geomorphology
Engineering geology & geomorphologyEngineering geology & geomorphology
Engineering geology & geomorphology
 
Sistema digestivo
Sistema digestivoSistema digestivo
Sistema digestivo
 
Horarios y aulas primer cuatrimestre 2017- al 01 de marzo 2017
Horarios y aulas  primer cuatrimestre 2017- al 01 de marzo 2017Horarios y aulas  primer cuatrimestre 2017- al 01 de marzo 2017
Horarios y aulas primer cuatrimestre 2017- al 01 de marzo 2017
 
Guide to investing in the Australian mining industry - March 2017
Guide to investing in the Australian mining industry - March 2017Guide to investing in the Australian mining industry - March 2017
Guide to investing in the Australian mining industry - March 2017
 
Actividad 8: Paulina Ramos Castro 6°A
Actividad 8: Paulina Ramos Castro 6°AActividad 8: Paulina Ramos Castro 6°A
Actividad 8: Paulina Ramos Castro 6°A
 
Perspectives 2017: Pat Bradley
Perspectives 2017: Pat BradleyPerspectives 2017: Pat Bradley
Perspectives 2017: Pat Bradley
 
Volumenes de transito_2010_2011
Volumenes de transito_2010_2011Volumenes de transito_2010_2011
Volumenes de transito_2010_2011
 
משחקי בילוש פרזנטציה, אלונים אור יהודה
משחקי בילוש פרזנטציה, אלונים אור יהודהמשחקי בילוש פרזנטציה, אלונים אור יהודה
משחקי בילוש פרזנטציה, אלונים אור יהודה
 
Visite sous la mer puis sur terre
Visite sous la mer puis sur terreVisite sous la mer puis sur terre
Visite sous la mer puis sur terre
 
Congestion de transito -el problema y como enfrentarlo-CEPAL 87
Congestion de transito -el problema y como enfrentarlo-CEPAL 87Congestion de transito -el problema y como enfrentarlo-CEPAL 87
Congestion de transito -el problema y como enfrentarlo-CEPAL 87
 
2 lina-y-diego-nic1
2 lina-y-diego-nic12 lina-y-diego-nic1
2 lina-y-diego-nic1
 
功夫微講堂第五卷
功夫微講堂第五卷功夫微講堂第五卷
功夫微講堂第五卷
 
Des belles a Canet
Des belles a CanetDes belles a Canet
Des belles a Canet
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

PHP Date and Time Function

  • 1. For date and time function we know first few things in our mind Date and time function Capital S Year Day Month Th,rd,st y—17 d=06 m=03 Example--1st Y—2017 n= 6 M=mar l= Monday,tue.... F=march D=Mon J=3
  • 2. By using [date_default_timezone_get(); using this function we can get the time which is by default set. date_default_timezone_set(“Asian/Calcutt a”); By using this function we can get the current time of the current city or country.
  • 3. To set the time  date_default_timezone_set(“Asian/Culcu tta”);  Echo date(“h:i:s a); date(h:i:s A);  Date(h:i:p); date(h:i:s P);  Am-anti mariadian  Pm-post mariadian
  • 4. Define the time  G-24hr-1,2,3,4,5---------13,14,15,-------- 22,23  H-24hr-01,02,03,04,05----13,14,15------ 22,23  g-12hr-1,2,3,4,5,--------11,12,1,2,3,-------11  h-12hr-01,02,03-----11,12,01,02,03-------11
  • 5.  date_default_timezone_set(“Asian/Calcutta”) ;  echo date(“d,l,F,y,g:i:s a”);  Output- 06,Monday,March,17 10:58:06 am Example
  • 6. We also get output like below  echo date(todayis l);  Output---today is Monday  echo “today is “.date(“l”);  Output---today is Monday
  • 7. echo time();  By using this function we can get the number of seconds and we can also call it as unix timestamp. (1971-2017(or current time))  echo (time()-1296000); 129600 is 15 days sec  echo date(“y-m-d h:i:s a”,(time()-+1296000));  o/p-17-02-19 11:10:50am (15 day back if - 1296000) or +1296000 then its (17-03-21 11:10:51)
  • 8. Strtotime(); using this function we can get the time of befor or after any year (like 10 years ,20 years before or after)  strtotime(-10 years);  strtotime(+20 years);
  • 9. Example-difference between the date or years  $birth=“1990-02-12”;  $past=strtotime($birth);  $curr=time();  echo(($curr-$past)/(86400*365)); year  86400 is seconds for a day  echo(($curr-$past)/(86400*30)); month  echo(($curr-$past)/(86400*7)); week