Hi Guys,
How could I convert a date/time to an Unix TimeStamp?
#ifdef __XHARBOUR__
#xtranslate HB_STOT( <c> ) => STOT( <c> )
#xtranslate HB_DateTime() => DateTime()
#endif
//----------------------------------------------------------------------------//
function FW_DateToUnix( tDateTime ) // ( dDate or tDateTime ) --> nMilliSecs
DEFAULT tDateTime := HB_DateTime()
return INT( ( FW_DTOT( tDateTime ) - HB_STOT( "19700101000000" ) ) * 86400000.0 )
//----------------------------------------------------------------------------//
function FW_UnixToDate( nMilliSecs ) // --> tDateTime
if ValType( nMilliSecs ) == "C"
nMilliSecs := Val( nMilliSecs )
else
DEFAULT nMilliSecs := 0
endif
return HB_STOT( "19700101000000" ) + ( nMilliSecs / 86400000.0 )
//----------------------------------------------------------------------------//
vilian wrote:Hi Guys,
How could I convert a date/time to an Unix TimeStamp?
UNIX_TIMESTAMP( <datetime> )
FROM_UNIXTIM( nUnixTime )
? oCn:QueryResult( "SELECT UNIX_TIMESTAMP( ? )", { HB_DateTime() } )
? oCn:QueryResult( "SELECT FROM_UNIXTIME( ? , '%d-%m-%Y %H:%i:%S')", { nUnixTimeInSeconds} )
SET DATE BRIT
myDate := Hb_Dtot(Ctod("23/05/2023"),"18:00:00")
? FW_DateToUnix( MyDate ) //168486480000
? FW_DateToUnix( UTC_TIMESTAMP() )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 85 guests