AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.11.2010, 04:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Dynamics AX Sustained Engineering: Date\time data reflected in User's preferred time zone after conversion from UTC Blog bot DAX Blogs 0 10.08.2010 02:07
jinx: Dynamics AX AIF Webservices – Date, Time und Datetime Datentypen Blog bot DAX auf Deutsch 0 12.06.2010 01:05
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
axaptapedia: Batch processing Blog bot DAX Blogs 0 29.01.2009 17:05
axaptapedia: WMI Blog bot DAX Blogs 0 20.07.2007 18:00

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 08:54.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.