Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date calculation

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
OK, this is a bit complicated scenario. I am currently designing a forum and I want to calculate the posts per day for a user. I have only got the users date of registration (Format: DD,MM,YYYY,HH,MM,SS) and the post count. To calculate the posts per day, I have to find out the days from the registration to the current date (only the days not the exact time). How is that possible?
 
Use the Date object's
Code:
.valueOf()
function which returns the milliseconds elapsed since the base date.

Code:
(today.valueOf()-registered.valueOf())/(1000*60*60*24)

Once you have the millisecond difference between dates, convert it to days. Then you can
Code:
Math.round()
it if you want.
 
Great, there's only one problem. In the forum the registration date is stored in a string with the format "DD.MM.YYYY HH:MM". So I have to convert it to a "valid" date to use the valueOf function right? So how do I do that?
 
Great, there's only one problem. In the forum the registration date is stored in a string with the format "DD.MM.YYYY HH:MM". So I have to convert it to a "valid" date to use the valueOf function right? So how do I do that?
 
Great, there's only one problem. In the forum the registration date is stored in a string with the format "DD.MM.YYYY HH:MM". So I have to convert it to a "valid" date to use the valueOf function right? So how do I do that?
 
Great, there's only one problem. In the forum the registration date is stored in a string with the format "DD.MM.YYYY HH:MM". So I have to convert it to a "valid" date to use the valueOf function right? So how do I do that?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top