Sponsored Content
Top Forums Shell Programming and Scripting Python script to convert date to iso format Post 302864563 by targzeta on Wednesday 16th of October 2013 05:33:33 PM
Old 10-16-2013
Code:
from time import strptime, strftime

date_in = '10/16/2013'

date_out = strftime('%Y-%m-%d', strptime(date_in, '%m/%d/%Y'))

print date_out

Emanuele
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert mmddyy date format to ccyyddd format??

hi, for reading a cobol indexed file i need to convert "mmddyy" date format to "ccyyddd" format. i checked the datecalc and other scripts but couldnt modify them to cater to my need:(... The datecalc gives an output which i believe is the total days till that date, but i want to convert it... (2 Replies)
Discussion started by: Bhups
2 Replies

2. UNIX for Dummies Questions & Answers

Convert date format

Hi All, Need your help in converting a date format in ksh. I'm currently working on SUN os where my script is getting a date from a table. The result returns to ksh in this format: 17-JUL-08 How do i convert this string to a date format like yyyymmdd? I tried #!/bin/ksh d="17-JUL-08"... (5 Replies)
Discussion started by: agathaeleanor
5 Replies

3. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

4. Shell Programming and Scripting

convert date format

I've been using this thread: https://www.unix.com/shell-programming-scripting/58675-change-date-dd-mmm-yyyy-mm-dd-yyyy.html and https://www.unix.com/shell-programming-scripting/14655-changing-yyyy-mm-dd-ddmmyy.html and this code: on this format: 05/16/2008 18:30:49 Installation 48985and I'm... (3 Replies)
Discussion started by: dba_frog
3 Replies

5. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

6. Shell Programming and Scripting

Date Format not working in python script

Good Morning, I am working on a pyhton script, where it has to fetch a file from our vendor's server over an ftp. The file is having a date format of "MMDDYYYY" (i have included in my python script), but when the script is executed it is unable to fetch the file. At the same time, if i... (1 Reply)
Discussion started by: AReddy
1 Replies

7. Shell Programming and Scripting

Convert string into date format

Hi, I am getting the below string as a input for date. 12/03/2013 11:02 AM I want to change this date as 03-DEC-2013 11:02 AM. Could you please help on this. Thanks Chelladurai (4 Replies)
Discussion started by: ckchelladurai
4 Replies

8. Shell Programming and Scripting

Convert Date Format

Hello, I want to change the format of date value in variable. e.g. cur_date = '2013/03/13 14:24:50' (yyyy/mm/dd hh24:mi:ss) I want to change this to '13-MAR-2013 14:24:50 Following code coverts the current date to format I am looking for. But I do not know how this can be done for a date... (8 Replies)
Discussion started by: cartrider
8 Replies

9. Shell Programming and Scripting

Convert date format

Hi guys I am looking to convert this kind of entry in a txt file 26/04/2008 to April 2008 Note : this is not using the date command , these are date entries in a file can i do this with sed ? Use code tags, thanks. (5 Replies)
Discussion started by: johnnybananas
5 Replies

10. Shell Programming and Scripting

Convert excel to csv in python date not display exactly

Hi, Anyone can help I am just converting the excel file to csv using python, I can get the conversion output but the date not display exactly. test.xlsx date format 167 1588 risks/SCS JP CAMPANA & CIE.pdf SCS JP CAMPANA & CIE 2 1 1 0 2015-03-16 16:56:25 167 1146 risks/AirBNB... (1 Reply)
Discussion started by: fspalero
1 Replies
STRPTIME(3)								 1							       STRPTIME(3)

strptime - Parse a time/date generated withstrftime(3)

SYNOPSIS
array strptime (string $date, string $format) DESCRIPTION
strptime(3) returns an array with the $date parsed, or FALSE on error. Month and weekday names and other language dependent strings respect the current locale set with setlocale(3) ( LC_TIME). PARAMETERS
o $date ( string) - The string to parse (e.g. returned from strftime(3)). o $format ( string) - The format used in $date (e.g. the same as used in strftime(3)). Note that some of the format options available to strf- time(3) may not have any effect within strptime(3); the exact subset that are supported will vary based on the operating system and C library in use. For more information about the format options, read the strftime(3) page. RETURN VALUES
Returns an array or FALSE on failure. The following parameters are returned in the array +-----------+---------------------------------------------------+ |parameters | | | | | | | Description | | | | +-----------+---------------------------------------------------+ | | | | "tm_sec" | | | | | | | Seconds after the minute (0-61) | | | | | | | | "tm_min" | | | | | | | Minutes after the hour (0-59) | | | | | | | |"tm_hour" | | | | | | | Hour since midnight (0-23) | | | | | | | |"tm_mday" | | | | | | | Day of the month (1-31) | | | | | | | | "tm_mon" | | | | | | | Months since January (0-11) | | | | | | | |"tm_year" | | | | | | | Years since 1900 | | | | | | | |"tm_wday" | | | | | | | Days since Sunday (0-6) | | | | | | | |"tm_yday" | | | | | | | Days since January 1 (0-365) | | | | | | | |"unparsed" | | | | | | | the $date part which was not recognized using the | | | specified $format | | | | +-----------+---------------------------------------------------+ EXAMPLES
Example #1 strptime(3) example <?php $format = '%d/%m/%Y %H:%M:%S'; $strf = strftime($format); echo "$strf "; print_r(strptime($strf, $format)); ?> The above example will output something similar to: 03/10/2004 15:54:19 Array ( [tm_sec] => 19 [tm_min] => 54 [tm_hour] => 15 [tm_mday] => 3 [tm_mon] => 9 [tm_year] => 104 [tm_wday] => 0 [tm_yday] => 276 [unparsed] => ) NOTES
Note This function is not implemented on Windows platforms. Note Internally, this function calls the strptime() function provided by the system's C library. This function can exhibit noticeably different behaviour across different operating systems. The use of date_parse_from_format(3), which does not suffer from these issues, is recommended on PHP 5.3.0 and later. Note "tm_sec" includes any leap seconds (currently upto 2 a year). For more information on leap seconds, see the Wikipedia article on leap seconds. Note Prior to PHP 5.2.0, this function could return undefined behaviour. Notably, the "tm_sec", "tm_min" and "tm_hour" entries would return undefined values. SEE ALSO
checkdate(3), strftime(3), date_parse_from_format(3), DateTime.createFromFormat(3). PHP Documentation Group STRPTIME(3)
All times are GMT -4. The time now is 12:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy