Is there a way to retrieve the time an object was created at?
A more general answer would be to import java. util. Date , then when you need to set a timestamp equal to the current date, simply set it equal to new Date() .
MySQL TIMESTAMP() FunctionThe TIMESTAMP() function returns a datetime value based on a date or datetime value. Note: If there are specified two arguments with this function, it first adds the second argument to the first, and then returns a datetime value.
Not generally but you can do it for objects you create yourself via
R> df <- data.frame(a=sample(LETTERS[1:5],10,TRUE),b=runif(10))
R> attr(df, "createdAt") <- Sys.time()
R> df
a b
1 B 0.8437021
2 D 0.8683446
3 B 0.5194791
4 B 0.0480405
5 B 0.5604978
6 C 0.1938154
7 A 0.1451077
8 D 0.1785405
9 C 0.3937795
10 B 0.2874135
R> str(df)
'data.frame': 10 obs. of 2 variables:
$ a: Factor w/ 4 levels "A","B","C","D": 2 4 2 2 2 3 1 4 3 2
$ b: num 0.844 0.868 0.519 0.048 0.56 ...
- attr(*, "createdAt")= POSIXct, format: "2011-03-16 10:42:10.137434"
R>
and you can then write yourself some custom print()
or show()
functions that use the attribute. Frank Harrell's rms and its Design predecessor have done something like that for a long time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With