473,698 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strtotime() pre-1970 ?

if I code

$birth = strtotime('1 April 1950');

then $birth = -1, I guess that this is because time "began" on 1st Jan,
1970. (although I seem to remember a few good times before that).

So, what's the easiest way to find out how many days old I am (exactly,
please, not just taking 1 April 1970 and adding 20 *365, which does not
account for leap years?)

Thanks in advance.

Sep 26 '06 #1
2 2989
Baron Samedi schrieb:
if I code

$birth = strtotime('1 April 1950');

then $birth = -1, I guess that this is because time "began" on 1st Jan,
1970. (although I seem to remember a few good times before that).

So, what's the easiest way to find out how many days old I am (exactly,
please, not just taking 1 April 1970 and adding 20 *365, which does not
account for leap years?)

Thanks in advance.
Have a look at the safestrtotime() function suggested in the user
contributed notes in the PHP manual:
http://ch2.php.net/manual/de/functio...time.php#54564

HTH
Markus
Sep 26 '06 #2

Markus Ernst wrote:
Baron Samedi schrieb:
if I code

$birth = strtotime('1 April 1950');

then $birth = -1, I guess that this is because time "began" on 1st Jan,
1970. (although I seem to remember a few good times before that).

So, what's the easiest way to find out how many days old I am (exactly,
please, not just taking 1 April 1970 and adding 20 *365, which does not
account for leap years?)

Thanks in advance.

Have a look at the safestrtotime() function suggested in the user
contributed notes in the PHP manual:
http://ch2.php.net/manual/de/functio...time.php#54564
Thanks, that wokred a treat!

Sep 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4648
by: Pjotr Wedersteers | last post by:
I'm using strtotime to get the timestamp for midnight. I have a statistics script for my pagecounter that displays hits since midnight. I also display the number of hours and minutes passed since midnight. $start = strtotime ('today 00:00'); $timepassed = date ('H:i', time () - $start); The weird part is at 11.30 AM it says 12 hrs and 30 minutes have passed. I tried adding GMT+1 like so: $start = strtotime ('today 00:00 GMT+1');...
1
2164
by: peabody | last post by:
I'm trying to use the strtotime() function to manage sessions. But I get the following <?php print(time() . " - " . strtotime("+1 hour")); ?> outputs: 1097380666 - 1097308800
5
4821
by: Leif K-Brooks | last post by:
PHP has a very nice strtotime function (http://php.net/strtotime) which converts a date/time in virtually any format into a timestamp. Does Python have a similar function?
7
5369
by: Rithish | last post by:
Hello. I noticed a strange thing while using strtotime() and date() functions in combination to generate from MySQL into a readable format. By default, the MySQL date field will be 0000-00-00 00:00:00 When I pass this to strtotime() to generate the timestamp, and then pass it to the date function, it generates 30-11-1999. <? print ( "<br> strtotime for '0000-00-00 00:00:00' : " . strtotime (
18
1963
by: windandwaves | last post by:
Hi Folk I love the strtotime function, because I can make a date field in a form and just tell my users to enter whatever they want and as long as it is a date, it will work. HOWEVER, this obviously does not work for the day/month vs month/day scenario. That is, in New Zealand we use day/month/year, while the function assumes it to be month/day/year.
6
1526
by: Brian Kendig | last post by:
I'm working with dates in several formats including 'yyyy MMM dd', but strtotime doesn't recognize this format and returns FALSE. Is there a direct way to convert times from this format into timestamps, other than my having to whip up a simple parsing routine? My headache is that I use strtotime in a lot of places in a lot of files, and I'd hate to have to add a wrapper everyplace I use it. I wish there were a way to extend strtotime's...
5
13716
by: Chris | last post by:
I am trying to output Monday of the current week i.e. if Monday is the 8th I want to display 'Monday 8th' for any date between Monday 8-14th. I would appreciate any help, the code below is heading in the right direction but doesn't quite give me the results I am looking for. $givenday = mktime(0,0,0,10,08,2007); $Monday = strtotime("Monday this week",$givenday); echo date("j M Y H:i:s", $Monday);
3
1978
by: Anthony Smith | last post by:
So, after doing some research I finally figured that php chokes on dates past year 2525. In this web service that I use they often use 2525-05-31 as the expiration date. I want to determine how I can convert this in a format to compare it with other dates. Before I was trying this: if (strtotime($territory->expirationDate) < strtotime("2008-01-01")){ /do something }
9
1820
by: Erwin Moller | last post by:
Hi group, I have been using strtotime a lot in my code. I wonder if I made a mistake in my thinking. :-/ Here follows a stripped down example. consider some dates: $date1 = "2008-02-23"; $date2 = "2008-02-23"; (They are the same)
1
2418
dlite922
by: dlite922 | last post by:
I'm not sure if it's a bug or maybe some weird way strtotime() works, but I need dates for 1. Second Sunday of March 2. First Sunday of November for any given year (mostly current year). This
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.