Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   ¿Existen funciones en Delphi que retornen el día y la hora? (https://www.clubdelphi.com/foros/showthread.php?t=62376)

noob 18-12-2008 22:40:27

¿Existen funciones en Delphi que retornen el día y la hora?
 
Estoy tratando de dar con ello pero no lo encuentro, ¿se puede hacer esto?
Gracias.

Kipow 18-12-2008 22:44:18

De la ayuda de Delphi. :)



Código:

Function NOW();



Returns the current date and time.


 Pascal
  function Now: TDateTime;

 C++
  TDateTime Now();

 File
    SysUtils



 Description
    Returns the current date and time, corresponding to the sum  of the value

returned by the global Date and Time functions.

Note: Although TDateTime values can represent  milliseconds, Now is
accurate only to the nearest second.


noob 18-12-2008 22:44:53

Muchas gracias.

Caro 19-12-2008 00:02:47

Hola noob, para obtener el día y la hora existen varias funciones, con Now como te han indicado obtienes la fecha y hora actual. Una forma podría ser utilizar las funciones DayOf y TimeOf o también puedes utilizar el procedimiento DecodeDateTime al cual le pasas una fecha y las variables donde quieres que te devuelva la fecha y hora desagregada.

Código Delphi [-]
 
 Showmessage('Dia: '+IntToStr(DayOf(Now))+' Hora:'+TimeToStr(TimeOf(Now)));
 
 //Donde Anio, Mes, Dia, Hora, minuto, segundo, milisegundo son variables de tipo Word
   DecodeDateTime(Now, Anio, Mes, Dia, Hora, minuto, segundo, milisegundo);

Saluditos


La franja horaria es GMT +2. Ahora son las 18:43:55.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi