date

Incrementing current date by 5 minutes in bash

安稳与你 提交于 2021-02-04 16:23:34
问题 In my script I'm storing the current in date in a variable, however I would like the variable to store the date 5 minutes ahead. 29/10/2014-10:47:06 to 29/10/2014-10:52:06 Is there a quick and easy way to do this in Bash? Looking for a solution that would also work correctly if the time was 10:59:00 for example (recognising to enter the next hour). I've found some Perl solutions but nothing for Bash. 回答1: You can use the -d option: $ date mercredi 29 octobre 2014, 11:45:45 (UTC+0100) $ date

Incrementing current date by 5 minutes in bash

℡╲_俬逩灬. 提交于 2021-02-04 16:21:49
问题 In my script I'm storing the current in date in a variable, however I would like the variable to store the date 5 minutes ahead. 29/10/2014-10:47:06 to 29/10/2014-10:52:06 Is there a quick and easy way to do this in Bash? Looking for a solution that would also work correctly if the time was 10:59:00 for example (recognising to enter the next hour). I've found some Perl solutions but nothing for Bash. 回答1: You can use the -d option: $ date mercredi 29 octobre 2014, 11:45:45 (UTC+0100) $ date

How do you set a strftime with javascript?

旧城冷巷雨未停 提交于 2021-02-04 14:25:22
问题 I need to custom format dates. In ruby, I would use strftime, or string formatted time, to accomplish this. now = Time.new now.strftime '%a, %d of %b' #=> "Sat, 27 of Jun" Does javascript use strftime or some equivalent? How can I get a similar effect in javascript? 回答1: UPDATE Arguments of toLocaleString method can also configure the format of the dates. This is supported in modern browser versions, you can see more information here. let date = new Date(Date.UTC(2015, 5, 27, 12, 0, 0)) ,

Most appropriate SQL and Java data types for storing date and time [duplicate]

我与影子孤独终老i 提交于 2021-02-04 13:24:52
问题 This question already has answers here : Handling MySQL datetimes and timestamps in Java (3 answers) Closed 4 years ago . Apologies in advance for the somewhat broad question. What are the most appropriate MySQL and Java data types for handling date and times with the following format: yyyy.MM.dd hh:mm:ss I need to be able to convert a String representation of the date & time into the given Date Format as well as then store that date&time in the database. I then need to do the reverse and

Moment format returns invalid date

大城市里の小女人 提交于 2021-02-04 12:21:48
问题 i have a date which i formated using moment to be shown like this: 03/04/2105. I want to transform it to iso using moment again. As a result i'm writing: const IsoDateTo = moment(dateTo).format('YYYY-MM-DD[T]HH:mm:ss'); The date to is 23/04/2105 but the IsoDateTo is returning something like this: 2105-03-04T00:00:00 Also when i enter a date greater than 12 it returns me Invalid Date. Why is this happening? 回答1: To make sure that you are correctly parsing the string you want to pass the

How to extract only 'Day' value from full 'Date' string?

不想你离开。 提交于 2021-02-04 09:57:05
问题 I have an array of Date values in the format of 'Y-m-d' . I want to loop over the array and only extract the day ( 'd' ) of each member, but can't figure out to split it. Do I use substrings in some way? Put simply, I have '2010-11-24' , and I want to get just '24' from that. The problem being the day could be either single or double figures. 回答1: If you have PHP < 5.3, use strtotime(): $string = "2010-11-24"; $timestamp = strtotime($string); echo date("d", $timestamp); If you have PHP >= 5.3

Python - Get Yesterday's date as a string in YYYY-MM-DD format

廉价感情. 提交于 2021-02-04 09:18:46
问题 As an input to an API request I need to get yesterday's date as a string in the format YYYY-MM-DD . I have a working version which is: yesterday = datetime.date.fromordinal(datetime.date.today().toordinal()-1) report_date = str(yesterday.year) + \ ('-' if len(str(yesterday.month)) == 2 else '-0') + str(yesterday.month) + \ ('-' if len(str(yesterday.day)) == 2 else '-0') + str(yesterday.day) There must be a more elegant way to do this, interested for educational purposes as much as anything

Python - Get Yesterday's date as a string in YYYY-MM-DD format

孤人 提交于 2021-02-04 09:18:25
问题 As an input to an API request I need to get yesterday's date as a string in the format YYYY-MM-DD . I have a working version which is: yesterday = datetime.date.fromordinal(datetime.date.today().toordinal()-1) report_date = str(yesterday.year) + \ ('-' if len(str(yesterday.month)) == 2 else '-0') + str(yesterday.month) + \ ('-' if len(str(yesterday.day)) == 2 else '-0') + str(yesterday.day) There must be a more elegant way to do this, interested for educational purposes as much as anything

DateTimeParse Exception

妖精的绣舞 提交于 2021-02-04 08:42:11
问题 I am constantly getting an exception error in my code when parsing a date. The Date looks like this: Wed May 21 00:00:00 EDT 2008 This is the code for trying to read it: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy"); Property property = new Property(); property.setSale_date(LocalDateTime.parse(linesplit[8], formatter)); Expected result: A LocalDateTime of 2008-05-21T00:00 . What I got instead: Exception in thread "main" java.time.format

Invalid date is populated when we use yyyy-MM-dd'T'HH:mm:ssXXX format in java [duplicate]

a 夏天 提交于 2021-02-04 08:41:09
问题 This question already has answers here : “EEE MMM dd HH:mm:ss ZZZ yyyy” date format to java.sql.Date (2 answers) java.util.Date is generating a wrong date? (3 answers) Closed 1 year ago . When we convert the date from yyyy-MM-dd'T'HH:mm:ssXXX to YYMMDD date is invalid. Say.. If the date is 2019-02-27T12:52:58.249Z then the converted date is generated as "190258" 回答1: The issue is because of 'D' in the input format. D represents Day of the year - so when we give 2019-02-27 it adds the 31 days