Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,900 questions

51,831 answers

573 users

How to convert time in milliseconds to number of years in Pascal

1 Answer

0 votes
program MillisecondsToYears;

uses
  SysUtils;

const
  MS_PER_SECOND = 1000;
  SECONDS_PER_MINUTE = 60;
  MINUTES_PER_HOUR = 60;
  HOURS_PER_DAY = 24;
  DAYS_PER_YEAR = 365.25;

function MillisecondsToYears(ms: Int64): Double;
begin
  MillisecondsToYears := ms / (MS_PER_SECOND * SECONDS_PER_MINUTE * 
                               MINUTES_PER_HOUR * HOURS_PER_DAY * DAYS_PER_YEAR);
end;

var
  milliseconds: Int64;
  years: Double;

begin
  milliseconds := 1476907455894; 
  
  years := MillisecondsToYears(milliseconds);
  
  WriteLn('Years: ', FormatFloat('0.00', years));
end.



(*
run:

Years: 46.80

*)

 



answered Dec 20, 2024 by avibootz
edited Dec 20, 2024 by avibootz
...