Hi Guys,
How could I convert a date/time to an Unix TimeStamp?
Hi Guys,
How could I convert a date/time to an Unix TimeStamp?
We have already implemented those functions for FWH already
Please lets wait for Mr. Rao comments about them
#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,If you want to use this functionality with MySql, you can use the MySql built-in functions
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() )