Time string to timestamp [duplicate] - php

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")

Related

strtotime not working for long time addition [duplicate]

This question already has answers here:
Accessing dates in PHP beyond 2038
(5 answers)
Closed 7 years ago.
I need a date which is 35 years ahead of a date which is user input.
With the following code in php
$DoCndm=date("Y-m-d",strtotime($_POST['DoH'] ." +35 years"));
I found that it works correctly upto 22 years but returns output as 1970-01-01 for 23 and above.. Is it a bug ??
Read this link Year 2038 problem
You can not use unix timstamp above 2038 year

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

Need to convert a string(time) in sql to real date in php [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Converting a UNIX Timestamp to Formatted Date String
(10 answers)
Closed 7 years ago.
I have a table with a time (int 4) where is stored time ex:1506201203
That would be:
year-mo-da-hh-mm
2015-06-20-12-03
I need a php script to get the time and display it correctly ..
A bit of help ?
You can use from_unixtime.
FROM_UNIXTIME(column_name, '%Y-%m-%d') in your MySQL query.
Or you can just use date function.
date('Y-m-d-h-m', $n['date']).

how to compare dates [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to Compare Dates in php?
I have these two dates
1305004066
1305007443
I want to compare which one is later on than other. How can I do that
If it's UNIX timestamps (seconds since 1970-01-01), the largest one is the latest:
$latest = max($time1, $time2);

string to php timestamp [duplicate]

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'));

Categories