I have PHP times for the start and end times of an event. This is a simple <?php time(); ?> for some future date’s start and end time. I was wondering if anyone knew of a way to take either the numerical format (PHP time()) or taking some string value representing that time (I could do a strtotime($sometimevalue);) and turn
Tag: datetime
How to set date.timezone for CodeIgniter to work with php 5.3
When date.timezone in php.ini is commented out, it gives me: A PHP Error was encountered Severity: Warning Message: main(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely
How can I get today’s timestamp in PHP
I tried but when I output it I still get the time eg “22 Jan 2011 4:53:59 pm”. Why is that? UPDATE Ah… many people misunderstood me, my bad, I forgot to point out the main point. I created the date with just the date portion, I don’t want the time. So I’d expect something like Answer You can call
Calculate total seconds in PHP DateInterval
What is the best way to calculate the total number of seconds between two dates? So far, I’ve tried something along the lines of: However, the days property of the DateInterval object seems to be broken in the current PHP5.3 build (at least on Windows, it always returns the same 6015 value). I also attempted to do it in a
Converting to date in PHP from yyyymmdd format
I have dates in the following format (yyyymmdd, 18751104, 19140722)… what’s the easiest way to convert it to date()…. or is using mktime() and substrings my best option…?
The first day of the current month in php using date_modify as DateTime object
I can get the Monday of this week with: I would like to get with the same ease the 1st of this month. How can I achieve that? Answer Requires PHP 5.3 to work (“first day of” is introduced in PHP 5.3). Otherwise the example above is the only way to do it: In PHP 5.4+ you can do this:
Finding the number of days between two dates
How to find number of days between two dates using PHP? Answer
How to generate random date between two dates using php?
I am coding an application where i need to assign random date between two fixed timestamps how i can achieve this using php i’ve searched first but only found the answer for Java not php for example : Answer PHP has the rand() function: It also has mt_rand(), which is generally purported to have better randomness in the results: To
MySQL datetime fields and daylight savings time — how do I reference the “extra” hour?
I’m using the America/New York timezone. In the Fall we “fall back” an hour — effectively “gaining” one hour at 2am. At the transition point the following happens: it’s 01:59:00 -04:00 then 1 …
Getting Hour and Minute in PHP
I need to get the current time, in Hour:Min format can any one help me in this. Answer Should do it, for the current time. Use a lower case h for 12 hour clock instead of 24 hour. More date time formats listed here.