string to php timestamp [duplicate] - php

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
convert any date string to timestamp without timezone
I have a string that looks like this and want a php timestamp format.
I can ask client to change format of the string if necessary.
2010/08/11 06:33:00

Use strtotime:
$date = date('Y/m/d H:i:s', strtotime('2010/08/11 06:33:00'));

Related

How to get a format of the given date or time in php? [duplicate]

This question already has answers here:
PHP function to get the date format?
(6 answers)
Closed 11 months ago.
How to get a format of the given date or time in php?
If I give date like this,
2022-03-08 06:45:06
It should return "Y-m-d H:i:s"
Is there any possible way to get the format from date?
i dont think there is such a function.
if you need to handle dates in different formats, reformat them in timestamp and then in the needed format
you can try something like this
$timestamp = strtotime("2022-03-08 06:45:06");
$newFormat = date('Y-m-d', $timestamp)

Change Date format from 2018-09-27T18:30:00.000Z to 2018-09-27 13:17:14 [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 4 years ago.
When I select a date using angular md-datepicker I receive date in 2018-09-27T18:30:00.000Z this format but in my database i have dates in 2018-09-27 13:17:14 this format, how can I convert dates in PHP to search in the database please help me.
First create DateTime object then change to format whatever you want.
$dateTime = new DateTime('2018-09-27T18:30:00.000Z');
$databaseFormat = $dateTime->format('Y-m-d H:i:s');

PHP Convert Date/Time format from 'd/m/Y H:i:s' to 'H:i:s'? [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 7 years ago.
I have a timestamp column in my database with dates and times formatted like '24/06/2015 14:30', but I need to convert it to just '14:30'. I've tried everything please help.
Very easy to use, just pass in argument and format: http://php.net/manual/en/class.datetime.php

php - date format ISO 8601 [duplicate]

This question already has answers here:
How do I convert an ISO8601 date to another format in PHP?
(2 answers)
Closed 9 years ago.
I have encountered this date format:
2013-03-12T09:16:12.1550656+01:00
from what I have found in net this is ISO 8601 (am I correct?).
How can I convert this this date format using php?
I can generate it easily using date('c'), but I need convert this type of date:
20130422122037 - (YYYYMMDDHHMMSS)
Try this:
$date = new DateTime('20130422122037');
var_dump($date->format('c'));

Time string to timestamp [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Is it possible to get UNIX time from such date 2011-02-27 02:04:46?
How can I convert a PHP timestamp like 2011-05-04 10:35:57 to Unix epoch time (in seconds)?
strtotime("2011-05-04 10:35:57")

Categories