The strptime() function parses the time/date generated using strftime(). This function returns a parsed date array, or FALSE if an error occurs. The following parameters will be returned in an array.
[tm_sec] − Seconds (0-61)
[tm_min] − Minutes (0-59)
[tm_hour] − hour (0-23)
[tm_mday] − day of month (1-31)
-
[tm_mon] − Number of months since January (0-11)
[tm_year] − Number of years since 1900
-
[tm_wday] − Number of days since Sunday (0-6)
-
[tm_yday] − Number of days since January 1 (0-365)
[unparsed] − Use the unrecognized date part (if any) of the specified format
Syntax
strptime(date, format)
Parameters
date − The string to parse
-
format − The format of the date and use the following Format as −
%a − abbreviated day of the week name
- ##%A − full day of the week name
- %b − abbreviated month name
- %B − full month name
- %c − preferred Date and time representation
- %C − Century (year divided by 100, range 00 to 99)
- %d − Month date (01 to 31)
- %D − Same as %m/%d/%y
- %e − Day in the month (1 to 31)
- %g − Similar to %G, but does not include the century
- %G − Corresponds to the ISO week number 4-digit year (see %V)
- %h − Same as %b ##%H − Hour, using 24-hour format (00 to 23)
- %I − hour, using 12-hour format (01 to 12)
- %j − number of days in year (001 to 12) 366)
- %m − Month (01 to 12)
- %M − Minute
- %n − Line break
- %p − AM or PM depending on the given time value
- %r − AM and PM representation Time
- ##%R − Time in 24-hour format
- %S − Seconds
- %t − Tab character
- %T − Current time, equivalent to %H:%M:%S
- %u − Day of the week A few are numbers (1 to 7), Monday is 1. Warning: Sunday is 1
- %U in Sun Solaris - the number of weeks in the year, starting with the first Sunday as the first day of the first week
- %V − ISO 8601 week number (01 to 53) in the current year, where week 1 has at least 4 days in the current year and Monday is the first day of the week
- %W − The number of weeks in the current year, starting from the first Monday as the first day of the first week
- %w − The number of the day of the week, Sunday is 0
##%x − Preferred date representation, excluding time
- ##%X − Preferred time representation, excluding date
- %y − The year does not include the century (range is 00 to 99)
- %Y − The year includes the century
- %Z or %z − time zone or name or abbreviation
- %% − literal % character
-
<?php
$format = '%d/%m/%Y %H:%M:%S';
$strf = strftime($format);
echo "$strf</p><p>";
print_r(strptime($strf, $format));
?>
OutputThe following is the output −11/10/2018 05:18:13 Array ( [tm_sec] => 13 [tm_min] => 18 [tm_hour] => 5 [tm_mday] => 11 [tm_mon] => 9 [tm_year] => 118 [tm_wday] => 4 [tm_yday] => 283 [unparsed] => )
The above is the detailed content of strptime() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
