Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Help: calculating the year,month,days of Age using javascript

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
10-11-2012, 09:30 AM   PM User | #1
vinek4
New to the CF scene

Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Help: calculating the year,month,days of Age using javascript

guys.. i have some problem regarding this... JAVASCRIPT

Quote:
 Untitled Document

Year/s Month/s Day/s

Hour/s Minute/s Second/s

 10-11-2012, 09:44 AM PM User | #2 Philip M Supreme Master coder!     Join Date: Jun 2002 Location: London, England Posts: 17,487 Thanks: 200 Thanked 2,471 Times in 2,449 Posts As you are working with seconds you would do best to use the getTime() method which returns the number of milliseconds between midnight of January 1, 1970 and the specified date. You can then compare the value for now with the user's birthdate and convert the difference to days, hours, minutes, seconds. Code: ```function secondsToString(seconds) { var numdays = Math.floor(seconds / 86400); var numhours = Math.floor((seconds % 86400) / 3600); var numminutes = Math.floor(((seconds % 86400) % 3600) / 60); var numseconds = ((seconds % 86400) % 3600) % 60; return numdays + " days " + numhours + " hours " + numminutes + " minutes " + numseconds + " seconds"; }``` It is tricky to calculate the number of months between two dates as the number of days in each month varies. You may find this useful:- Code: ``` DaysWeeksMonths

Enter from and to dates MM/DD/YYYY

From: To:
How many Days:
How many Weeks:
How many Months:
How many Years:
``` But does anyone really care about their age in hours, minutes, seconds? Or knows the time of their birth that accurately? Obviously the hours, minutes, seconds calculated from midnight on the birthday are not at all an accurate statement - meaningless in fact.. Or is this just a homework exercise? You can shorten your code to var mName = ["January","February","March","April","May","June","July","August","September","October","November"," December"];

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 12:40 AM.