##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::chrono::system_clock::now

From cppreference.com
< cpp‎ | chrono‎ | system clock

[edit template]

static std::chrono::time_point<std::chrono::system_clock> now(); |  | (since C++11)

Returns a time point representing with the current point in time.

### [edit] Parameters

(none)

### [edit] Return value

A time point representing the current time.

### [edit] Exceptions

`noexcept` specification:
noexcept

### [edit] Example

Run this code

    #include <iostream>
    #include <vector>
    #include <chrono>

    int main()
    {
        for (unsigned long long size = 1; size < 10000000; size *= 10) {
            auto start = std::chrono::system_clock::now();
            std::vector<int> v(size, 42);
            auto end = std::chrono::system_clock::now();

            auto elapsed = end - start;
            std::cout << size << ": " << elapsed.count() << '\n';
        }
    }

Possible output:

    1: 1
    10: 2
    100: 3
    1000: 6
    10000: 47
    100000: 507
    1000000: 4822

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/chrono/system_clock/now&oldid=50431"