17.11.2010, 04:12 | #1 |
Участник
|
axaptapedia: Current Time
Источник: http://www.axaptapedia.com/Current_Time
============== Summary: New page: Different ways of getting the current time ====Retrieves the session date if it has been set, otherwise returns the system date==== // TimeNow() retrieves the current system time. pr... Different ways of getting the current time ====Retrieves the session date if it has been set, otherwise returns the system date==== // TimeNow() retrieves the current system time. print strFmt("%1 %2", SystemDateGet(), time2Str(timeNow(), 1, 1)); // 16.11.2010 21:59:20 ====Returns the local machine's date==== // TimeNow() retrieves the current system time. print strFmt("%1 %2", today(), time2Str(timeNow(), 1, 1)); // 16.11.2010 21:59:21 ====Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time==== print System.DateTime::get_Now(); // 16.11.2010 21:59:21 ====Gets a Coordinated Universal Time (UTC) DateTime object that is set to the current date and time on this computer==== print System.DateTime::get_UtcNow().ToLocalTime(); // 16.11.2010 21:59:21 ====Gets the current system time==== print DateTimeUtil::applyTimeZoneOffset( DateTimeUtil::utcNow(), DateTimeUtil::getClientMachineTimeZone()); // 16.11.2010 21:59:21 ====Returns the current DateTime set in the system, not the current machine dateTime==== print DateTimeUtil::applyTimeZoneOffset( DateTimeUtil::getSystemDateTime(), DateTimeUtil::getClientMachineTimeZone()); // 16.11.2010 21:59:20 ====Creates a new COMVariant object and initializes it with a time value in one operation==== COMVariant cOMVariant; ; cOMVariant = COMVariant::createFromTime(timeNow()); print cOMVariant.ToString() // 16.11.2010 21:59:21 VT_DATE ====Gets the current time on the database server==== SysSQLSystemInfo systemInfo = SysSQLSystemInfo::construct(); System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(); System.Data.SqlClient.SqlConnection connect; System.Data.SqlClient.SqlCommand command; ; builder.set_DataSource(systemInfo.getLoginServer()); builder.set_InitialCatalog(systemInfo.getloginDatabase()); builder.set_IntegratedSecurity(true); command = new System.Data.SqlClient.SqlCommand( 'SELECT GETDATE()', new System.Data.SqlClient.SqlConnection(builder.ToString())); connect = command.get_Connection(); connect.Open(); print command.ExecuteScalar(); command.Dispose(); connect.Dispose(); // 16.11.2010 21:59:19 ====Gets the current time from the local computer==== COM WMIService; COM localTime; COM time; ; WMIService = COM::getObjectEx(@'winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2'); localTime = WMIService.ExecQuery('Select * from Win32_LocalTime'); time = new COMEnum2Object(localTime).getFirst(); print mkdate(time.day(), time.month(), time.year()), strFmt(" %1:%2:%3", time.hour(), time.minute(), time.second()); // 16.11.2010 21:59:21 ====Gets the current time from a remote server==== System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(); System.Net.Sockets.NetworkStream networkStream; System.Text.Encoding encoding; System.Byte[] bytes; System.TimeZone timeZone; int receiveBufferSize; container result; ; tcpClient.Connect('time-b.nist.gov', 13); networkStream = tcpClient.GetStream(); receiveBufferSize = tcpClient.get_ReceiveBufferSize(); bytes = new System.Byte[receiveBufferSize](); networkStream.Read(bytes, 0, receiveBufferSize); tcpClient.Close(); encoding = System.Text.Encoding::get_ASCII(); result = str2Con(encoding.GetString(bytes), ' '); timeZone = System.TimeZone::get_CurrentTimeZone(); print timeZone.ToLocalTime(str2datetime(conPeek(result, 2) + ' ' + conPeek(result, 3), 321)); // 16.11.2010 21:59:22 Источник: http://www.axaptapedia.com/Current_Time
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|