xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
date_time_now.cpp
Shows how to use
xtd::date_time::now
property.
#include <xtd/xtd>
using namespace
xtd::globalization
;
class
program {
public
:
static
auto
main() {
auto
local_date =
date_time::now
();
auto
utc_date =
date_time::utc_now
();
auto
culture_names =
array
{
"en-US"
,
"en-GB"
,
"fr-FR"
,
"de-DE"
,
"ru-RU"
};
for
(
auto
culture_name : culture_names) {
auto
culture =
culture_info
{culture_name};
console::write_line
(
"{}:"
, culture.native_name());
console::write_line
(
" Local date and time: {}, {}"
, local_date.to_string(culture), local_date.kind());
console::write_line
(
" UTC date and time: {}, {}\n"
, utc_date.to_string(culture), utc_date.kind());
}
}
};
startup_
(program::main);
// This code can produce the following output :
//
// English (United States):
// Local date and time: 10/23/2025 0:59:10 AM, local
// UTC date and time: 10/22/2025 10:59:10 PM, utc
//
// English (United Kingdom):
// Local date and time: 23/10/2025 00:59:10, local
// UTC date and time: 22/10/2025 22:59:10, utc
//
// français (France):
// Local date and time: 23/10/2025 00:59:10, local
// UTC date and time: 22/10/2025 22:59:10, utc
//
// Deutsch (Deutschland):
// Local date and time: 23.10.2025 00:59:10, local
// UTC date and time: 22.10.2025 22:59:10, utc
//
// русский (Россия):
// Local date and time: 23.10.2025 00:59:10, local
// UTC date and time: 22.10.2025 22:59:10, utc
xtd::array
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition
array.hpp:64
xtd::console::write_line
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
xtd::date_time::now
static auto now() noexcept -> date_time
Gets a xtd::date_time object that is set to the current date and time on this computer,...
xtd::date_time::utc_now
static auto utc_now() noexcept -> date_time
Gets a xtd::date_time object that is set to the current date and time on this computer,...
xtd::globalization::culture_info
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition
culture_info.hpp:42
startup_
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition
startup.hpp:284
xtd::globalization
Contains classes that define culture-related information, including language, country/region,...
Definition
culture_info.hpp:19
Generated on
for xtd by
Gammasoft
. All rights reserved.