Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In my application, the user gives 2 inputs — one is date and the other is time:
$date = date("d-M-Y");
$time=date("h:m:s");
How can I calculate a time stamp from these two variables in PHP?
actually i take the date form date picker and time from time oicker.....
If you want time stamp then use this
echo strtotime($date.' '.$time);
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to add the current time when the user has submitted the form in database?
You can get the timestamp with PHP's DateTime->setTimeStamp() method.
For DateTime, use something like this
$date = new DateTime();
$timestamp=$date->format("Y-m-d H:i:s'); //Returns something like 2013-12-7 11:10:14
If you're looking to do this in MySQL as opposed to PHP, use the CURRENT_TIMESTAMP() method
use date() function of php to get the current time.
$adate=date("Y-m-d");
or you can use NOW() in mysql to insert the current time in mysql.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I get and set a variable to the Eastern time zone and then use it in an "if" statement?
In one of my table I have a datetime column called gameEasternTime. Values are listed like so "2013-09-22 20:30:00"
I need to show a html div only if the Eastern time is after the time listed in my gameEasternTime column.
if ( $easternTime > schedule[gameEasternTime] ) {
echo ' <div> ';
}
Use date_default_timezone_set('America/New_York') and DateTime::format . Yes, those are links.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to add a page in my website by which I want conduct online exams. I want that my page is activate for 3 hours only. After 3 hours the page will submit itself as happens in online exams. Can any one give me any script how to make my page time constraint?
$time = date('Y-m-d H:i:s');
extract the hour from the date and do this
if ($hour > 10800){ // 10800 which is equal to 3 hours in seconds.
submit the exam
}
don't rely on javascript to set the time because the javascript may be disabled.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm using this to get the number of days between two dates:
$nbDays = $dateArrival->diff($dateDeparture);
I can use "->format()" if I want to output this to the screen. But how can I transform this into an INT if I want to use the number of days in a multiplication?
diff() returns a DateInterval which has a public days property.
$nbDays = $dateArrival->diff($dateDeparture);
echo $nbDays->days;
The return value of DateTime::diff is a DateInterval. If you look at the documentation, you will see that class has a days field which you can use to get an integer number of days.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i want to increment the current date by one month which is in d/m/Y format
but i have no idea about this,can any one give me a relevant example.
thanks in advance
In PHP you do this:
$time = strtotime("+1 month", time());
$date = date("d/m/Y", $time);