473,786 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert string to date object?

6 New Member
i have date in string in this format
eg. 1/20/21011 i need to convert it into the date object
Jan 25 '11 #1
4 3651
bvdet
2,851 Recognized Expert Moderator Specialist
Expand|Select|Wrap|Line Numbers
  1. >>> import time
  2. >>> s = "1/20/2011"
  3. >>> time.strptime(s, "%m/%d/%Y")
  4. (2011, 1, 20, 0, 0, 0, 3, 20, -1)
  5. >>> 
Jan 25 '11 #2
Shivareddy
6 New Member
thanks i tried it and it works fine i alos tried same for time also but i get problem when the time is provide in this format
10:30:00 AM
Jan 26 '11 #3
bvdet
2,851 Recognized Expert Moderator Specialist
Expand|Select|Wrap|Line Numbers
  1. >>> import time
  2. >>> s = "1/20/2011 10:30:00 AM"
  3. >>> time.strptime(s, "%m/%d/%Y %I:%M:%S %p")
  4. (2011, 1, 20, 10, 30, 0, 3, 20, -1)
  5. >>> time.strptime("1/20/2011 10:30:00 PM", "%m/%d/%Y %I:%M:%S %p")
  6. (2011, 1, 20, 22, 30, 0, 3, 20, -1)
  7. >>> 
Jan 26 '11 #4
Shivareddy
6 New Member
Thanks very much
Jan 26 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
51214
by: JimMenees | last post by:
I know there's an easy answer to this which is escaping me: -------------------------------------------------------------------------- ----------------------- I have clickable thumb images which pass the image info to a window open script to display a larger version of the image along with a description of the image. The image info comes from the image element; the description string is in a hidden form var with the same name as the...
7
3988
by: Mick White | last post by:
According to the Safari browser the world began on "Fri Dec 13 1901 15:45:52 GMT-0500", but I need to be able to get around this limitation. I am interested in dates from 1500 to 1901, as far as I can determine, there are 14 possible calendar variations. Year starts on Sun, Mon..... Leap year starts on Sun, Mon.. I can label these early year "types" as a number between 0 and 13.
2
10883
by: Abhishek Srivastava | last post by:
Hello All, I wrote the following program. using System; using System.Globalization; public class ShortDateTest { public static void Main(string args)
1
3116
by: ABC | last post by:
How to convert a date string to datetime value with custom date format? e.g. Date String Date Format Result (DateTime value) "05/07/2004" "MM/dd/yyyy" May 7, 2004 "01062005" "ddMMyyyy" June 1, 2005 "09-07-05" "MM-dd-yy" Sept 7, 2005 Is there any functions to convert?
1
4548
by: Sam | last post by:
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on following guideline found at Internet? To convert Julian date to Gregorian date: double JD = 2299160.5; double Z = Math.Floor(JD+0.5); double W = Math.Floor((Z - 1867216.25)/36524.25); double X = Math.Floor(W/4);
1
5737
by: xendrax | last post by:
I was told on this site eval was bad but its the only way i can work out how to do it.. their example was use var imdesc = document.myform.value not var imdesc = eval("document.myform." + imagename1 + ".value") but i could not see how to change mine to emulate it... I have a function displaytable() which i pass the id of a div into so: displaytable(MyLayer1) - shows the first table hidden in the <div id=MyLayer1>...
5
12721
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
6
3257
by: Gretsch | last post by:
Hi, I have some XML data which contains a date in dd/mm/yyyy format (ie UK date format). In javascript I need to read this date then calculate the age (in days& decimals) of the XML data. I can get today's date in milliseconds: var current_date = new Date(); var date1_ms = current_date.getTime(); but I can't see how to read the XMLdate in UK format, I have the XML date (string) in a var called docdate & I thought this should...
7
3677
devonknows
by: devonknows | last post by:
Hi, The problem im having is, Im creating a user control. The user (via the Property Page's) will set his own menu titles, and the choose a form of which that title links to. If that makes sense. So the form names are stored in string data, how can i convert it from a string to an object or to a form so that when someone clicks on the title the form will show. Is there a way to loop though form names? But i dont want to have to add and ...
4
2311
by: Tony B | last post by:
I'm looking to convert a string in "dd/MM/yy" format into a date object. How do I go about this ?
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.