Is there a way to check to see if a date/time is valid you would think these would be easy to check:
$date = '0000-00-00';
$time = '00:00:00';
$dateTime = $date . ' ' . $time;
if(strtotime($dateTime)) {
// why is this valid?
}
what really gets me is this:
echo date('Y-m-d', strtotime($date));
results in: "1999-11-30",
huh? i ...
Say I have a string coming in, "2007-02-28", what's the simplest code I could write to turn that into "2007-03-01"? Right now I'm just using strtotime(), then adding 24*60*60, then using date(), but just wondering if there is a cleaner, simpler, or more clever way of doing it.
...
I'm writing a function that works out whether or not the time is between 9am and 5pm on a working day. It then tells you when the next working day starts (if currently out of business hours) based on whether today's business hours have ended or (if after midnight) are about to begin.
All is going well so far, and to create the most rea...
I'm using strtotime to create a timestamp from some ropey XML, but the timezone is incorrect.
How can I remove 5 hours from the time?
...
I am a complete newbie in PHP. I would like to show the number of days missing for a specific date. In other words, I want to display something like:
"X days to go for the great event"
using PHP and the server time.
How is this accomplished?
...
Hi,
This was working fine yesterday with no changes to the code.
echo date("M", strtotime("-3 month", time()) );
echo date("M", strtotime("-2 month", time()) );
echo date("M", strtotime("-1 month", time()) );
echo date("M", time());
The output it was producing yesterday was as you would expect- i.e. Apr, May, Jun, Jul
Today it echoe...
Here is my PHP code:
echo '<br />1. '.$w_time_no;
echo '<br />2. '.strtotime($w_time_no);
echo '<br />3. '.date('G:i', strtotime($w_time_no));
That's what I get:
1. 0000-00-00 22:00:00
2.
3. 2:00
Why strtotime() outputs nothing by itself? Is there something wrong with server settings? Server: Apache/2.2.11 (Win32), PHP 5.2.10, MySQ...
strtotime() in PHP can do the following transformations:
Inputs:
strtotime(’2004-02-12T15:19:21+00:00′);
strtotime(’Thu, 21 Dec 2000 16:01:07 +0200′);
strtotime(’Monday, January 1st’);
strtotime(’tomorrow’);
strtotime(’-1 week 2 days 4 hours 2 seconds’);
Outputs:
2004-02-12 07:02:21
2000-12-21 06:12:07
2009-01-01 12:01:00
2009-02-...
I have a datetime field (endTime) in mysql. I use gmdate() to populate this endTime field.
The value stored is something like 2009-09-17 04:10:48. I want to add 30 minutes to this endtime and compare it with current time. ie) the user is allowed to do a certain task only 30 minutes within his endTime. After 30 minutes of his endTime, ...
How do I have to write "+3 days at 12:34:56" to make strtotime() parse it properly?
...
Is there any functionality in Emacs Lisp that behaves similar to PHP's strtotime function? (Actually AFAIK it implements relative items of the GNU date input formats.)
In PHP I can write
echo strtotime("+2 months"); //1258891352
echo strtotime("-3 months +2 weeks"); //1246952239
which return the corresponding UNIX timestamps.
...
In PHP, how do I get the current time, in UTC, without hard coding knowledge of where my hosting provider is?
For example, I tried the following:
time() + strtotime('January 1, 2000')-strtotime('January 1, 2000 UTC')
and find that it reports a time that is one hour ahead of actual UTC time. I tried this on two different hosting prov...
I'm relatively new to CF / Flex3 and I've been tasked with making mock applications in order to get my knowledge of the 2 languages up.
I'm creating an application where I require data back 1 week (strtotime equiv '-1 week').
So that the result is always 1 weeks worth.
Whats the comparable equivalent if any for coldfusion? If none, h...
This is my code:
$testtime = str_replace('.', '-', '2009.07.08 17:01');
$timestamp = strtotime($testtime);
echo $timestamp . "\n";
echo $testtime . "\n";
echo date('Y-m-d H:t', $timestamp);
And this is my output:
1247065260
2009-07-08 17:01
2009-07-08 17:31
What's wrong?
Thank you in advance.
...
Hi,
I've been using strtotime("$day-$month-$year"), in my app and it works cool... but know I want to make some date comparisons still in this format but I'm not sure about what is precise,
It's as if any format goes
...
<?php
echo "Hello?";
$thetime = strtotime("Wed Dec 16 2009 00:00:00 GMT-0500 (Eastern Standard Time)");
var_dump($thetime);
?>
This code evaluates to "bool(false)"; however, just removing "(Eastern Standard Time)" allows the strtotime function to evaluate correctly. Any ideas why strtotime is choking on the time zone bit of the str...
I'm trying to get a date that is one year from the date I specify.
My code looks like this:
$futureDate=date('Y-m-d',strtotime('+one year',$startDate));
It's returning the wrong date.... any ideas why?
Thanks!
...
The following code
echo $lastmoment."<br/>";
echo time();
echo "<br/>";
echo strtotime($lastmoment);
outputs:
2009-12-15 17:40:53 1260876829
1260898853
What's wrong? $lastment is a past time stamp in MySQL, why is strtotime($lastmoment) bigger than time()?
...
Many examples are about adding days to this day. But how to do it, if I have different starding day?
For example (Does not work):
$day='2010-01-23';
// add 7 days to the date above
$NewDate= Date('$day', strtotime("+7 days"));
echo $NewDate;
Example above does not work. How should I change the starding day by putting something else ...
I'm trying to make a PHP script to find the next occurence of a date (say 5-1). However, if I put that into strtotime() on 5-2 it comes up with the date from this year. I simply want to make it always return the next date possible. How can I make this work? I'm using codeigniter if that helps.
EDIT: Here's some code I came up with, if s...